Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -19,10 +19,14 @@ construction_terms = [
|
|
| 19 |
]
|
| 20 |
|
| 21 |
# Inference function
|
| 22 |
-
def generate_captions(
|
| 23 |
captions = []
|
| 24 |
|
| 25 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
| 26 |
if image.mode != "RGB":
|
| 27 |
image = image.convert("RGB")
|
| 28 |
|
|
@@ -42,10 +46,10 @@ def generate_captions(images):
|
|
| 42 |
|
| 43 |
return captions
|
| 44 |
|
| 45 |
-
# Gradio interface
|
| 46 |
iface = gr.Interface(
|
| 47 |
fn=generate_captions,
|
| 48 |
-
inputs=gr.
|
| 49 |
outputs="text",
|
| 50 |
title="Construction Site Image-to-Text Generator",
|
| 51 |
description="Upload up to 10 site photos. The model will detect and describe construction activities and materials (e.g., concrete pouring, scaffolding, steel rods).",
|
|
|
|
| 19 |
]
|
| 20 |
|
| 21 |
# Inference function
|
| 22 |
+
def generate_captions(files):
|
| 23 |
captions = []
|
| 24 |
|
| 25 |
+
# Iterate through the uploaded images
|
| 26 |
+
for file in files:
|
| 27 |
+
# Open the image
|
| 28 |
+
image = Image.open(file.name)
|
| 29 |
+
|
| 30 |
if image.mode != "RGB":
|
| 31 |
image = image.convert("RGB")
|
| 32 |
|
|
|
|
| 46 |
|
| 47 |
return captions
|
| 48 |
|
| 49 |
+
# Gradio interface for uploading multiple files
|
| 50 |
iface = gr.Interface(
|
| 51 |
fn=generate_captions,
|
| 52 |
+
inputs=gr.Files(type="file", label="Upload Site Photos"), # Allow batch upload of images
|
| 53 |
outputs="text",
|
| 54 |
title="Construction Site Image-to-Text Generator",
|
| 55 |
description="Upload up to 10 site photos. The model will detect and describe construction activities and materials (e.g., concrete pouring, scaffolding, steel rods).",
|