diegocp01 commited on
Commit
3c5850d
·
verified ·
1 Parent(s): 3fdb736

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -12,22 +12,22 @@ client = genai.Client(api_key=API_KEY)
12
  def edit_image_with_gemini(image, text_input):
13
  """
14
  Edits an image using Gemini 2.0 Flash Experimental API based on a given text prompt.
15
-
16
  Parameters:
17
- image_path (str): Path to the input image.
18
- text_prompt (str): Text prompt describing the edit.
19
-
20
  Returns:
21
- Image: The modified image.
22
  """
23
-
24
  if image is None or not text_input:
25
  return "Please upload an image and provide an edit prompt.", None
26
 
 
 
 
27
  # Generate content with Gemini API
28
  response = client.models.generate_content(
29
  model="gemini-2.0-flash-exp-image-generation",
30
- contents=[text_input, image],
31
  config=types.GenerateContentConfig(
32
  response_modalities=['Text', 'Image']
33
  )
 
12
  def edit_image_with_gemini(image, text_input):
13
  """
14
  Edits an image using Gemini 2.0 Flash Experimental API based on a given text prompt.
 
15
  Parameters:
16
+ image (PIL.Image): The input image.
17
+ text_input (str): Text prompt describing the edit.
 
18
  Returns:
19
+ A tuple of status message and the modified image (or None).
20
  """
 
21
  if image is None or not text_input:
22
  return "Please upload an image and provide an edit prompt.", None
23
 
24
+ # Wrap text_input in a tuple to match the expected format
25
+ contents = [(text_input,), image]
26
+
27
  # Generate content with Gemini API
28
  response = client.models.generate_content(
29
  model="gemini-2.0-flash-exp-image-generation",
30
+ contents=contents,
31
  config=types.GenerateContentConfig(
32
  response_modalities=['Text', 'Image']
33
  )