Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -1,44 +1,42 @@
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
-
|
| 4 |
models = {
|
| 5 |
"Flux Lora": "models/prashanth970/flux-lora-uncensored",
|
| 6 |
"TrioHMH Flux": "models/DiegoJR1973/NSFW-TrioHMH-Flux",
|
| 7 |
"Master": "models/pimpilikipilapi1/NSFW_master"
|
| 8 |
}
|
| 9 |
|
| 10 |
-
|
| 11 |
def generate_image(text, model_name):
|
| 12 |
-
model_path = models[model_name]
|
| 13 |
print(f"Fetching model from: {model_path}")
|
| 14 |
|
| 15 |
try:
|
| 16 |
-
|
| 17 |
-
|
| 18 |
-
|
| 19 |
-
|
| 20 |
-
|
| 21 |
-
if isinstance(result_image, str): # if model returns a path to the image
|
| 22 |
-
return gr.Image(result_image)
|
| 23 |
-
elif isinstance(result_image, bytes): # if model returns raw image bytes
|
| 24 |
return gr.Image(value=result_image)
|
| 25 |
else:
|
| 26 |
return result_image
|
|
|
|
| 27 |
except Exception as e:
|
| 28 |
print(f"Error loading model: {e}")
|
| 29 |
return None
|
| 30 |
|
| 31 |
-
|
| 32 |
interface = gr.Interface(
|
| 33 |
fn=generate_image,
|
| 34 |
inputs=[
|
| 35 |
-
gr.Textbox(label="Type here your imagination:", placeholder="Type your description here..."),
|
| 36 |
-
gr.Dropdown(label="Select Model", choices=list(models.keys()), value="Flux Lora")
|
| 37 |
],
|
| 38 |
-
outputs=gr.Image(label="Generated Image"),
|
| 39 |
-
theme="NoCrypt/miku",
|
| 40 |
description="Sorry for the inconvenience. The model is currently running on the CPU, which might affect performance. We appreciate your understanding.",
|
| 41 |
)
|
| 42 |
|
| 43 |
-
|
| 44 |
-
interface.launch()
|
|
|
|
| 1 |
import gradio as gr
|
| 2 |
|
| 3 |
+
|
| 4 |
models = {
|
| 5 |
"Flux Lora": "models/prashanth970/flux-lora-uncensored",
|
| 6 |
"TrioHMH Flux": "models/DiegoJR1973/NSFW-TrioHMH-Flux",
|
| 7 |
"Master": "models/pimpilikipilapi1/NSFW_master"
|
| 8 |
}
|
| 9 |
|
| 10 |
+
|
| 11 |
def generate_image(text, model_name):
|
| 12 |
+
model_path = models[model_name]
|
| 13 |
print(f"Fetching model from: {model_path}")
|
| 14 |
|
| 15 |
try:
|
| 16 |
+
model = gr.load(model_path)
|
| 17 |
+
result_image = model(text)
|
| 18 |
+
if isinstance(result_image, str):
|
| 19 |
+
return gr.Image(value=result_image)
|
| 20 |
+
elif isinstance(result_image, bytes):
|
|
|
|
|
|
|
|
|
|
| 21 |
return gr.Image(value=result_image)
|
| 22 |
else:
|
| 23 |
return result_image
|
| 24 |
+
|
| 25 |
except Exception as e:
|
| 26 |
print(f"Error loading model: {e}")
|
| 27 |
return None
|
| 28 |
|
| 29 |
+
|
| 30 |
interface = gr.Interface(
|
| 31 |
fn=generate_image,
|
| 32 |
inputs=[
|
| 33 |
+
gr.Textbox(label="Type here your imagination:", placeholder="Type your description here..."),
|
| 34 |
+
gr.Dropdown(label="Select Model", choices=list(models.keys()), value="Flux Lora")
|
| 35 |
],
|
| 36 |
+
outputs=gr.Image(label="Generated Image"),
|
| 37 |
+
theme="NoCrypt/miku",
|
| 38 |
description="Sorry for the inconvenience. The model is currently running on the CPU, which might affect performance. We appreciate your understanding.",
|
| 39 |
)
|
| 40 |
|
| 41 |
+
|
| 42 |
+
interface.launch()
|