Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -2,13 +2,20 @@ import gradio as gr
|
|
| 2 |
import requests
|
| 3 |
import json
|
| 4 |
import time
|
|
|
|
| 5 |
|
| 6 |
url = "https://nexra.aryahcr.cc/api/image/complements"
|
| 7 |
headers = {
|
| 8 |
"Content-Type": "application/json"
|
| 9 |
}
|
| 10 |
|
|
|
|
|
|
|
|
|
|
| 11 |
def generate_image(prompt, model):
|
|
|
|
|
|
|
|
|
|
| 12 |
data = {
|
| 13 |
"prompt": prompt,
|
| 14 |
"model": model,
|
|
|
|
| 2 |
import requests
|
| 3 |
import json
|
| 4 |
import time
|
| 5 |
+
from profanity_check import predict # For NSFW detection
|
| 6 |
|
| 7 |
url = "https://nexra.aryahcr.cc/api/image/complements"
|
| 8 |
headers = {
|
| 9 |
"Content-Type": "application/json"
|
| 10 |
}
|
| 11 |
|
| 12 |
+
def is_nsfw(text):
|
| 13 |
+
return predict([text])[0] == 1
|
| 14 |
+
|
| 15 |
def generate_image(prompt, model):
|
| 16 |
+
if is_nsfw(prompt):
|
| 17 |
+
return "Error: Prompt contains inappropriate content."
|
| 18 |
+
|
| 19 |
data = {
|
| 20 |
"prompt": prompt,
|
| 21 |
"model": model,
|