BenK0y commited on
Commit
29688fe
·
verified ·
1 Parent(s): e68acf0

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +5 -5
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, text_input, image_loc):
60
  image_prompt = input_image_setup(image_loc)
61
- prompt_parts = [input_prompt + text_input, 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, text_input, social_media_platform, num_captions=1):
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 + f"Number of Captions/Posts: {num_captions}\n", text_input, file_paths[0])
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, text_input, social_media_input, num_captions_input)
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])