Commit 92eef44 1 parent decc6d7 commit 92eef44 Copy full SHA for 92eef44
File tree 1 file changed +3
-10
lines changed
1 file changed +3
-10
lines changed Original file line number Diff line number Diff line change 18
18
ENGINE_ID = "stable-diffusion-v1-6"
19
19
20
20
genai .configure (api_key = GEMINI_API_KEY )
21
-
22
21
generation_config = {
23
22
"temperature" : 1 ,
24
23
"top_p" : 0.95 ,
25
24
"top_k" : 64 ,
26
25
"max_output_tokens" : 8192 ,
27
26
"response_mime_type" : "text/plain" ,
28
27
}
29
-
30
28
model = genai .GenerativeModel (
31
29
model_name = "gemini-1.5-flash" ,
32
30
generation_config = generation_config ,
@@ -107,13 +105,8 @@ def edit_image(image_bytes, prompt):
107
105
108
106
response .raise_for_status ()
109
107
data = response .json ()
110
- images = data .get ("artifacts" , [])
111
-
112
- if not images :
113
- raise Exception ("No images generated." )
114
-
115
- return [base64 .b64decode (image ["base64" ]) for image in images ]
116
-
108
+ image_data = data ["artifacts" ][0 ]["base64" ]
109
+ return base64 .b64decode (image_data )
117
110
except Exception as e :
118
111
print (f"Error in edit_image: { e } " )
119
- return None
112
+ return None
You can’t perform that action at this time.
0 commit comments