Spaces:
Runtime error
Runtime error
Eeman Majumder commited on
Commit ·
ede0f90
1
Parent(s): ddd5092
anal
Browse files
app.py
CHANGED
|
@@ -10,8 +10,8 @@ import requests
|
|
| 10 |
st.title('Stable Diffusion (AI that can imagine)')
|
| 11 |
model_id = "CompVis/stable-diffusion-v1-4"
|
| 12 |
device = "cuda"
|
| 13 |
-
word_list_dataset = load_dataset("stabilityai/word-list", data_files="list.txt", use_auth_token=True)
|
| 14 |
-
word_list = word_list_dataset["train"]['text']
|
| 15 |
|
| 16 |
is_gpu_busy = False
|
| 17 |
def infer(prompt):
|
|
@@ -19,19 +19,19 @@ def infer(prompt):
|
|
| 19 |
samples = 4
|
| 20 |
steps = 50
|
| 21 |
scale = 7.5
|
| 22 |
-
#When running locally you can also remove this filter
|
| 23 |
-
for filter in word_list:
|
| 24 |
-
|
| 25 |
-
|
| 26 |
-
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
|
| 36 |
prompt=st.text_input('Enter your prompt')
|
| 37 |
true=st.button('Generate')
|
|
|
|
| 10 |
st.title('Stable Diffusion (AI that can imagine)')
|
| 11 |
model_id = "CompVis/stable-diffusion-v1-4"
|
| 12 |
device = "cuda"
|
| 13 |
+
# word_list_dataset = load_dataset("stabilityai/word-list", data_files="list.txt", use_auth_token=True)
|
| 14 |
+
# word_list = word_list_dataset["train"]['text']
|
| 15 |
|
| 16 |
is_gpu_busy = False
|
| 17 |
def infer(prompt):
|
|
|
|
| 19 |
samples = 4
|
| 20 |
steps = 50
|
| 21 |
scale = 7.5
|
| 22 |
+
# #When running locally you can also remove this filter
|
| 23 |
+
# for filter in word_list:
|
| 24 |
+
# if re.search(rf"\b{filter}\b", prompt):
|
| 25 |
+
# raise st.Error("Unsafe content found. Please try again with different prompts.")
|
| 26 |
+
images = []
|
| 27 |
+
url = os.getenv('JAX_BACKEND_URL')
|
| 28 |
+
payload = {'prompt': prompt}
|
| 29 |
+
images_request = requests.post(url, json = payload)
|
| 30 |
+
for image in images_request.json()["images"]:
|
| 31 |
+
image_b64 = (f"data:image/jpeg;base64,{image}")
|
| 32 |
+
images.append(image_b64)
|
| 33 |
+
st.image(images)
|
| 34 |
+
return images
|
| 35 |
|
| 36 |
prompt=st.text_input('Enter your prompt')
|
| 37 |
true=st.button('Generate')
|