Vnmrsharma commited on
Commit
33cb229
·
verified ·
1 Parent(s): 28a45b2

Uni-Imaginator-v1 Final Push

Browse files

Removed the redundant comments from the main-code and corrected the model's call.

Files changed (1) hide show
  1. app.py +3 -4
app.py CHANGED
@@ -26,13 +26,13 @@ PROMPT_VARIATIONS = [
26
  ]
27
 
28
  def process_variation(variation, input_image, product_name):
29
- """Process one variation: call the API, save the generated image to a temporary PNG file, and return its path."""
30
  text_input = (
31
  f"Hi, this is a picture of a product. The name of the product is {product_name}.",
32
  variation
33
  )
34
  response = client.models.generate_content(
35
- model=univin_model, # Use the 'univin' model name from the environment variable
36
  contents=[text_input, input_image],
37
  config=types.GenerateContentConfig(response_modalities=['Text', 'Image'])
38
  )
@@ -45,7 +45,7 @@ def process_variation(variation, input_image, product_name):
45
  return None
46
 
47
  def generate_images(input_image, product_name):
48
- """Generate images concurrently for the defined prompt variations (exactly 10 calls)."""
49
  with concurrent.futures.ThreadPoolExecutor() as executor:
50
  futures = [
51
  executor.submit(process_variation, variation, input_image, product_name)
@@ -61,7 +61,6 @@ with gr.Blocks() as demo:
61
  product_name = gr.Textbox(label="Product Name", placeholder="Enter the product name")
62
  generate_button = gr.Button("Generate Images")
63
 
64
- # The Gallery displays file paths so that each image downloads as a PNG file.
65
  gallery = gr.Gallery(label="Generated Images", elem_id="gallery", columns=4, height="auto", object_fit="contain", interactive=True)
66
 
67
  generate_button.click(fn=generate_images, inputs=[input_image, product_name], outputs=gallery)
 
26
  ]
27
 
28
  def process_variation(variation, input_image, product_name):
29
+ "
30
  text_input = (
31
  f"Hi, this is a picture of a product. The name of the product is {product_name}.",
32
  variation
33
  )
34
  response = client.models.generate_content(
35
+ model=univin_model,
36
  contents=[text_input, input_image],
37
  config=types.GenerateContentConfig(response_modalities=['Text', 'Image'])
38
  )
 
45
  return None
46
 
47
  def generate_images(input_image, product_name):
48
+
49
  with concurrent.futures.ThreadPoolExecutor() as executor:
50
  futures = [
51
  executor.submit(process_variation, variation, input_image, product_name)
 
61
  product_name = gr.Textbox(label="Product Name", placeholder="Enter the product name")
62
  generate_button = gr.Button("Generate Images")
63
 
 
64
  gallery = gr.Gallery(label="Generated Images", elem_id="gallery", columns=4, height="auto", object_fit="contain", interactive=True)
65
 
66
  generate_button.click(fn=generate_images, inputs=[input_image, product_name], outputs=gallery)