victorgg commited on
Commit
a240c67
·
verified ·
1 Parent(s): aca3f89

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -14,13 +14,13 @@ def configure_api_key(api_key):
14
  raise ValueError("No API key provided and GEMINI_API_KEY environment variable not set.")
15
  return key
16
 
17
- def generate_image_from_text(prompt, api_key, model_name="gemini-1.5-pro-002"): #Or using "gemini-1.0-pro-vision-001" or "gemini-pro"
18
  """Generates an image from a text prompt using a specified Gemini model.
19
 
20
  Args:
21
  prompt: The text prompt describing the desired image.
22
  api_key: Your Google AI API key.
23
- model_name: The name of the Gemini model to use (default: gemini-1.5-pro).
24
 
25
  Returns:
26
  A PIL.Image object representing the generated image, or None on error.
@@ -48,7 +48,7 @@ def generate_image_from_text(prompt, api_key, model_name="gemini-1.5-pro-002"):
48
  print(f"An error occurred during image generation: {e}")
49
  return None
50
 
51
- def edit_image(image_path, prompt, output_path, api_key, model_name="gemini-1.5-pro-002"): # Or "gemini-1.0-pro-vision-001"
52
  """Edits an image using a specified Gemini model and a text prompt.
53
 
54
  Args:
@@ -143,8 +143,8 @@ with gr.Blocks() as demo:
143
  examples = [
144
  [None, "A futuristic cityscape at night with flying cars"],
145
  [None, "A cat wearing a tiny hat"],
146
- ["data/1.webp", 'change text to "AMEER"'],
147
- ["data/2.webp", "remove the spoon from hand only"],
148
  ] #Combined both image editing and image generation examples.
149
 
150
  submit_btn.click(
@@ -159,4 +159,4 @@ with gr.Blocks() as demo:
159
  label="Try these examples"
160
  )
161
 
162
- demo.launch(share=True)
 
14
  raise ValueError("No API key provided and GEMINI_API_KEY environment variable not set.")
15
  return key
16
 
17
+ def generate_image_from_text(prompt, api_key, model_name="gemini-1.5-pro-002"): # Corrected model name
18
  """Generates an image from a text prompt using a specified Gemini model.
19
 
20
  Args:
21
  prompt: The text prompt describing the desired image.
22
  api_key: Your Google AI API key.
23
+ model_name: The name of the Gemini model to use (default: gemini-1.5-pro-002).
24
 
25
  Returns:
26
  A PIL.Image object representing the generated image, or None on error.
 
48
  print(f"An error occurred during image generation: {e}")
49
  return None
50
 
51
+ def edit_image(image_path, prompt, output_path, api_key, model_name="gemini-1.5-pro-002"): # Corrected model name
52
  """Edits an image using a specified Gemini model and a text prompt.
53
 
54
  Args:
 
143
  examples = [
144
  [None, "A futuristic cityscape at night with flying cars"],
145
  [None, "A cat wearing a tiny hat"],
146
+ ["data/1.webp", 'change text to "AMEER"'], # You'll need example images
147
+ ["data/2.webp", "remove the spoon from hand only"], # in a 'data' folder
148
  ] #Combined both image editing and image generation examples.
149
 
150
  submit_btn.click(
 
159
  label="Try these examples"
160
  )
161
 
162
+ demo.launch(share=True)