Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -4,7 +4,6 @@ import gradio as gr
|
|
4 |
import paddlehub as hub
|
5 |
import urllib
|
6 |
import cv2
|
7 |
-
from datasets import load_dataset
|
8 |
import re
|
9 |
import os
|
10 |
import requests
|
@@ -73,16 +72,12 @@ word_list = word_list_dataset["train"]['text']
|
|
73 |
|
74 |
def get_result(text_prompts, style_indx):
|
75 |
style = style_list[style_indx]
|
76 |
-
prompt = "," + style
|
77 |
-
for filter in word_list:
|
78 |
-
if re.search(rf"\b{filter}\b", text_prompts):
|
79 |
-
raise gr.Error("Unsafe content found. Please try again with different prompts.")
|
80 |
|
81 |
model_id = "runwayml/stable-diffusion-v1-5"
|
82 |
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
83 |
pipe = pipe.to("cuda")
|
84 |
|
85 |
-
prompt = text_prompts
|
86 |
image_output = pipe(prompt).images[0]
|
87 |
|
88 |
print("file name: " + image_output.filename)
|
@@ -109,6 +104,7 @@ def get_music(prompt):
|
|
109 |
with open("output.wav", "wb") as f:
|
110 |
f.write(wav[0].getbuffer())
|
111 |
return spec, 'output.wav'
|
|
|
112 |
|
113 |
def merge_video(music, img_list):
|
114 |
#Convert to mp3
|
|
|
4 |
import paddlehub as hub
|
5 |
import urllib
|
6 |
import cv2
|
|
|
7 |
import re
|
8 |
import os
|
9 |
import requests
|
|
|
72 |
|
73 |
def get_result(text_prompts, style_indx):
|
74 |
style = style_list[style_indx]
|
75 |
+
prompt = text_prompts + "," + style
|
|
|
|
|
|
|
76 |
|
77 |
model_id = "runwayml/stable-diffusion-v1-5"
|
78 |
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float16)
|
79 |
pipe = pipe.to("cuda")
|
80 |
|
|
|
81 |
image_output = pipe(prompt).images[0]
|
82 |
|
83 |
print("file name: " + image_output.filename)
|
|
|
104 |
with open("output.wav", "wb") as f:
|
105 |
f.write(wav[0].getbuffer())
|
106 |
return spec, 'output.wav'
|
107 |
+
|
108 |
|
109 |
def merge_video(music, img_list):
|
110 |
#Convert to mp3
|