Spaces:
Running
on
A10G
Running
on
A10G
darkstorm2150
commited on
Commit
•
0e6b2f0
1
Parent(s):
9f4b8d0
Update app.py
Browse files
app.py
CHANGED
@@ -63,7 +63,6 @@ def error_str(error, title="Error"):
|
|
63 |
else ""
|
64 |
)
|
65 |
|
66 |
-
|
67 |
def inference(
|
68 |
model_name,
|
69 |
prompt,
|
@@ -142,8 +141,7 @@ def txt_to_img(
|
|
142 |
if torch.cuda.is_available():
|
143 |
pipe = pipe.to("cuda")
|
144 |
pipe.enable_xformers_memory_efficient_attention()
|
145 |
-
|
146 |
-
else:
|
147 |
raise ValueError(f"Unable to find pipeline for model: {model_name}")
|
148 |
|
149 |
result = pipe(
|
@@ -163,7 +161,6 @@ def txt_to_img(
|
|
163 |
|
164 |
return replace_nsfw_images(result)
|
165 |
|
166 |
-
|
167 |
def img_to_img(
|
168 |
model_name,
|
169 |
prompt,
|
@@ -184,7 +181,6 @@ def img_to_img(
|
|
184 |
if torch.cuda.is_available():
|
185 |
pipe = pipe.to("cuda")
|
186 |
pipe.enable_xformers_memory_efficient_attention()
|
187 |
-
|
188 |
else:
|
189 |
raise ValueError(f"Unable to find pipeline for model: {model_name}")
|
190 |
|
@@ -208,14 +204,12 @@ def img_to_img(
|
|
208 |
|
209 |
return replace_nsfw_images(result)
|
210 |
|
211 |
-
|
212 |
def replace_nsfw_images(results):
|
213 |
for i in range(len(results.images)):
|
214 |
if results.nsfw_content_detected[i]:
|
215 |
results.images[i] = Image.open("nsfw.png")
|
216 |
return results.images
|
217 |
|
218 |
-
|
219 |
with gr.Blocks(css="style.css") as demo:
|
220 |
gr.HTML(
|
221 |
f"""
|
|
|
63 |
else ""
|
64 |
)
|
65 |
|
|
|
66 |
def inference(
|
67 |
model_name,
|
68 |
prompt,
|
|
|
141 |
if torch.cuda.is_available():
|
142 |
pipe = pipe.to("cuda")
|
143 |
pipe.enable_xformers_memory_efficient_attention()
|
144 |
+
else:
|
|
|
145 |
raise ValueError(f"Unable to find pipeline for model: {model_name}")
|
146 |
|
147 |
result = pipe(
|
|
|
161 |
|
162 |
return replace_nsfw_images(result)
|
163 |
|
|
|
164 |
def img_to_img(
|
165 |
model_name,
|
166 |
prompt,
|
|
|
181 |
if torch.cuda.is_available():
|
182 |
pipe = pipe.to("cuda")
|
183 |
pipe.enable_xformers_memory_efficient_attention()
|
|
|
184 |
else:
|
185 |
raise ValueError(f"Unable to find pipeline for model: {model_name}")
|
186 |
|
|
|
204 |
|
205 |
return replace_nsfw_images(result)
|
206 |
|
|
|
207 |
def replace_nsfw_images(results):
|
208 |
for i in range(len(results.images)):
|
209 |
if results.nsfw_content_detected[i]:
|
210 |
results.images[i] = Image.open("nsfw.png")
|
211 |
return results.images
|
212 |
|
|
|
213 |
with gr.Blocks(css="style.css") as demo:
|
214 |
gr.HTML(
|
215 |
f"""
|