Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
@@ -28,11 +28,11 @@ except Exception as e:
|
|
28 |
print(f"Error during Hugging Face login: {str(e)}")
|
29 |
|
30 |
# Set device: CUDA if available, else CPU
|
31 |
-
|
32 |
|
33 |
model_id1 = os.getenv("API_KEY")
|
34 |
pipe = StableDiffusionPipeline.from_pretrained(model_id1, torch_dtype=torch.float16, use_safetensors=True)
|
35 |
-
pipe = pipe.to(
|
36 |
|
37 |
# Updated function for text generation using the new API structure
|
38 |
def generate_creative_text(prompt):
|
@@ -81,7 +81,7 @@ def process_audio(audio_path, image_option, creative_text_option):
|
|
81 |
try:
|
82 |
model_id1 = "dreamlike-art/dreamlike-diffusion-1.0"
|
83 |
pipe = StableDiffusionPipeline.from_pretrained(model_id1, torch_dtype=torch.float16, use_safetensors=True)
|
84 |
-
pipe = pipe.to(
|
85 |
image = pipe(translation).images[0]
|
86 |
except Exception as e:
|
87 |
return tamil_text, translation, creative_text, f"An error occurred during image generation: {str(e)}"
|
|
|
28 |
print(f"Error during Hugging Face login: {str(e)}")
|
29 |
|
30 |
# Set device: CUDA if available, else CPU
|
31 |
+
device = torch.device('cuda' if torch.cuda.is_available() else 'cpu')
|
32 |
|
33 |
model_id1 = os.getenv("API_KEY")
|
34 |
pipe = StableDiffusionPipeline.from_pretrained(model_id1, torch_dtype=torch.float16, use_safetensors=True)
|
35 |
+
pipe = pipe.to(device)
|
36 |
|
37 |
# Updated function for text generation using the new API structure
|
38 |
def generate_creative_text(prompt):
|
|
|
81 |
try:
|
82 |
model_id1 = "dreamlike-art/dreamlike-diffusion-1.0"
|
83 |
pipe = StableDiffusionPipeline.from_pretrained(model_id1, torch_dtype=torch.float16, use_safetensors=True)
|
84 |
+
pipe = pipe.to(device)
|
85 |
image = pipe(translation).images[0]
|
86 |
except Exception as e:
|
87 |
return tamil_text, translation, creative_text, f"An error occurred during image generation: {str(e)}"
|