Spaces:
Running
Running
Update app.py
Browse files
app.py
CHANGED
@@ -35,19 +35,22 @@ async def generate_command(
|
|
35 |
img_count:int,
|
36 |
aspect_ratio: app_commands.Choice[str],
|
37 |
):
|
38 |
-
|
39 |
-
|
40 |
-
|
41 |
-
|
42 |
-
|
43 |
-
|
44 |
-
|
45 |
-
|
46 |
-
|
47 |
-
|
48 |
-
|
49 |
-
|
50 |
-
|
|
|
|
|
|
|
51 |
files = []
|
52 |
for i, image in enumerate(result.generated_images):
|
53 |
# Assuming `image` is a byte array or binary stream of the image
|
|
|
35 |
img_count:int,
|
36 |
aspect_ratio: app_commands.Choice[str],
|
37 |
):
|
38 |
+
try:
|
39 |
+
genai.configure(api_key=GEMINI_API_KEY)
|
40 |
+
imagen = genai.ImageGenerationModel("imagen-3.0-generate-001")
|
41 |
+
|
42 |
+
result = imagen.generate_images(
|
43 |
+
prompt=prompt,
|
44 |
+
number_of_images=img_count,
|
45 |
+
safety_filter_level="block_only_high",
|
46 |
+
person_generation="allow_adult",
|
47 |
+
aspect_ratio=aspect_ratio,
|
48 |
+
)
|
49 |
+
|
50 |
+
if result:
|
51 |
+
await interaction.followup.send(content=f"Successful request!")
|
52 |
+
except Exception as e:
|
53 |
+
interaction.followup.send(content=f"exception:{e}")
|
54 |
files = []
|
55 |
for i, image in enumerate(result.generated_images):
|
56 |
# Assuming `image` is a byte array or binary stream of the image
|