Rammohan0504 commited on
Commit
c4fefad
·
verified ·
1 Parent(s): cc1155e

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -4
app.py CHANGED
@@ -19,10 +19,14 @@ construction_terms = [
19
  ]
20
 
21
  # Inference function
22
- def generate_captions(images):
23
  captions = []
24
 
25
- for image in images:
 
 
 
 
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 (use `multiple=True` for batch image uploads)
46
  iface = gr.Interface(
47
  fn=generate_captions,
48
- inputs=gr.Image(type="pil", label="Upload Site Photos", multiple=True), # Batch upload of up to 10 images
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).",