Vnmrsharma commited on
Commit
2ab4d4a
·
verified ·
1 Parent(s): cb0d099

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +9 -4
app.py CHANGED
@@ -5,8 +5,13 @@ from PIL import Image
5
  from io import BytesIO
6
  import tempfile
7
  import concurrent.futures
 
 
 
 
 
 
8
 
9
- client = genai.Client(os.environ.getattribute(API_KEY))
10
  PROMPT_VARIATIONS = [
11
  "Generate a high quality image with a minimalist white background, bright natural light, and an open lid. Keep the product text unchanged.",
12
  "Generate a high quality image of a beautiful woman who is using the product. The product and its text must remain exactly as in the original image.",
@@ -27,7 +32,7 @@ def process_variation(variation, input_image, product_name):
27
  variation
28
  )
29
  response = client.models.generate_content(
30
- model=os.environ.getattribute(univin),
31
  contents=[text_input, input_image],
32
  config=types.GenerateContentConfig(response_modalities=['Text', 'Image'])
33
  )
@@ -50,7 +55,7 @@ def generate_images(input_image, product_name):
50
  return output_files
51
 
52
  with gr.Blocks() as demo:
53
- gr.Markdown("#Uni-Imaginator")
54
  with gr.Row():
55
  input_image = gr.Image(type="pil", label="Upload Image")
56
  product_name = gr.Textbox(label="Product Name", placeholder="Enter the product name")
@@ -61,4 +66,4 @@ with gr.Blocks() as demo:
61
 
62
  generate_button.click(fn=generate_images, inputs=[input_image, product_name], outputs=gallery)
63
 
64
- demo.launch()
 
5
  from io import BytesIO
6
  import tempfile
7
  import concurrent.futures
8
+ import os
9
+
10
+ api_key = os.environ.get("API_KEY")
11
+ univin_model = os.environ.get("univin")
12
+
13
+ client = genai.Client(api_key=api_key)
14
 
 
15
  PROMPT_VARIATIONS = [
16
  "Generate a high quality image with a minimalist white background, bright natural light, and an open lid. Keep the product text unchanged.",
17
  "Generate a high quality image of a beautiful woman who is using the product. The product and its text must remain exactly as in the original image.",
 
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
  )
 
55
  return output_files
56
 
57
  with gr.Blocks() as demo:
58
+ gr.Markdown("# Uni-Imaginator")
59
  with gr.Row():
60
  input_image = gr.Image(type="pil", label="Upload Image")
61
  product_name = gr.Textbox(label="Product Name", placeholder="Enter the product name")
 
66
 
67
  generate_button.click(fn=generate_images, inputs=[input_image, product_name], outputs=gallery)
68
 
69
+ demo.launch()