Update main.py
Browse files
main.py
CHANGED
@@ -22,11 +22,11 @@ def generate_caption(image_path):
|
|
22 |
|
23 |
# Route to handle image uploads and generate captions
|
24 |
@app.post("/uploadfile/")
|
25 |
-
async def generate_image_caption(
|
26 |
try:
|
27 |
# Save the uploaded image to a temporary file
|
28 |
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
|
29 |
-
shutil.copyfileobj(
|
30 |
temp_file_path = temp_file.name
|
31 |
|
32 |
# Generate caption for the uploaded image
|
|
|
22 |
|
23 |
# Route to handle image uploads and generate captions
|
24 |
@app.post("/uploadfile/")
|
25 |
+
async def generate_image_caption(file: UploadFile = File(...)):
|
26 |
try:
|
27 |
# Save the uploaded image to a temporary file
|
28 |
with tempfile.NamedTemporaryFile(delete=False) as temp_file:
|
29 |
+
shutil.copyfileobj(file.file, temp_file)
|
30 |
temp_file_path = temp_file.name
|
31 |
|
32 |
# Generate caption for the uploaded image
|