Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -56,19 +56,19 @@ def input_image_setup(file_loc):
|
|
| 56 |
]
|
| 57 |
return image_parts
|
| 58 |
|
| 59 |
-
def generate_gemini_response(input_prompt,
|
| 60 |
image_prompt = input_image_setup(image_loc)
|
| 61 |
-
prompt_parts = [input_prompt
|
| 62 |
response = model.generate_content(prompt_parts)
|
| 63 |
return response.text
|
| 64 |
|
| 65 |
input_prompt = """ Give the plate and the color of the car """
|
| 66 |
|
| 67 |
-
def upload_file(files
|
| 68 |
if not files:
|
| 69 |
return None, "Image not uploaded"
|
| 70 |
file_paths = [file.name for file in files]
|
| 71 |
-
response = generate_gemini_response(input_prompt
|
| 72 |
return file_paths[0], response
|
| 73 |
|
| 74 |
with gr.Blocks() as demo:
|
|
@@ -82,7 +82,7 @@ with gr.Blocks() as demo:
|
|
| 82 |
def process_generate(files):
|
| 83 |
if not files:
|
| 84 |
return None, "Image not uploaded"
|
| 85 |
-
return upload_file(files
|
| 86 |
|
| 87 |
upload_button.upload(fn=lambda files: files[0].name if files else None, inputs=[upload_button], outputs=image_output)
|
| 88 |
generate_button.click(fn=process_generate, inputs=[upload_button], outputs=[image_output, file_output])
|
|
|
|
| 56 |
]
|
| 57 |
return image_parts
|
| 58 |
|
| 59 |
+
def generate_gemini_response(input_prompt, image_loc):
|
| 60 |
image_prompt = input_image_setup(image_loc)
|
| 61 |
+
prompt_parts = [input_prompt, image_prompt[0]]
|
| 62 |
response = model.generate_content(prompt_parts)
|
| 63 |
return response.text
|
| 64 |
|
| 65 |
input_prompt = """ Give the plate and the color of the car """
|
| 66 |
|
| 67 |
+
def upload_file(files):
|
| 68 |
if not files:
|
| 69 |
return None, "Image not uploaded"
|
| 70 |
file_paths = [file.name for file in files]
|
| 71 |
+
response = generate_gemini_response(input_prompt, file_paths[0])
|
| 72 |
return file_paths[0], response
|
| 73 |
|
| 74 |
with gr.Blocks() as demo:
|
|
|
|
| 82 |
def process_generate(files):
|
| 83 |
if not files:
|
| 84 |
return None, "Image not uploaded"
|
| 85 |
+
return upload_file(files)
|
| 86 |
|
| 87 |
upload_button.upload(fn=lambda files: files[0].name if files else None, inputs=[upload_button], outputs=image_output)
|
| 88 |
generate_button.click(fn=process_generate, inputs=[upload_button], outputs=[image_output, file_output])
|