Update app.py
Browse files
app.py
CHANGED
@@ -20,7 +20,11 @@ pipe = DiffusionPipeline.from_pretrained(
|
|
20 |
"stabilityai/stable-diffusion-xl-base-1.0", # Remove torch_dtype and variant for CPU-friendly precision
|
21 |
)
|
22 |
|
23 |
-
|
|
|
|
|
|
|
|
|
24 |
|
25 |
# Function to generate image from text prompt using Stable Diffusion XL
|
26 |
def generate_image_from_text(translated_text):
|
@@ -93,5 +97,5 @@ iface = gr.Interface(
|
|
93 |
description="Input Tamil text, and this tool will translate it, generate a short paragraph, and create an image based on the translated text."
|
94 |
)
|
95 |
|
96 |
-
# Launch the Gradio app
|
97 |
-
iface.launch()
|
|
|
20 |
"stabilityai/stable-diffusion-xl-base-1.0", # Remove torch_dtype and variant for CPU-friendly precision
|
21 |
)
|
22 |
|
23 |
+
# Check if GPU is available and use it for inference
|
24 |
+
if torch.cuda.is_available():
|
25 |
+
pipe.to("cuda") # Use GPU for faster inference
|
26 |
+
else:
|
27 |
+
pipe.to("cpu") # Use CPU if GPU is not available
|
28 |
|
29 |
# Function to generate image from text prompt using Stable Diffusion XL
|
30 |
def generate_image_from_text(translated_text):
|
|
|
97 |
description="Input Tamil text, and this tool will translate it, generate a short paragraph, and create an image based on the translated text."
|
98 |
)
|
99 |
|
100 |
+
# Launch the Gradio app with share=True to create a shareable link
|
101 |
+
iface.launch(share=True)
|