Update app.py
Browse files
app.py
CHANGED
|
@@ -1,28 +1,27 @@
|
|
| 1 |
-
import os
|
| 2 |
-
import torch
|
| 3 |
-
from diffusers import StableDiffusionPipeline
|
| 4 |
-
import gradio as gr
|
| 5 |
|
| 6 |
-
|
| 7 |
-
|
|
|
|
| 8 |
|
| 9 |
-
#
|
| 10 |
pipe = StableDiffusionPipeline.from_pretrained(
|
| 11 |
"Linaqruf/anything-v3.0",
|
| 12 |
-
|
| 13 |
-
|
| 14 |
-
|
|
|
|
| 15 |
|
| 16 |
-
# Main generation function
|
| 17 |
def generate_thumbnail(prompt):
|
| 18 |
-
image = pipe(prompt).images[0]
|
| 19 |
return image
|
| 20 |
|
| 21 |
# Gradio UI
|
| 22 |
-
gr.Interface(
|
| 23 |
fn=generate_thumbnail,
|
| 24 |
-
inputs=gr.Textbox(label="
|
| 25 |
-
outputs=gr.Image(
|
| 26 |
-
title="Anime
|
| 27 |
-
description="
|
| 28 |
-
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
|
| 2 |
+
import gradio as gr
|
| 3 |
+
from diffusers import StableDiffusionPipeline
|
| 4 |
+
import torch
|
| 5 |
|
| 6 |
+
# Model load
|
| 7 |
pipe = StableDiffusionPipeline.from_pretrained(
|
| 8 |
"Linaqruf/anything-v3.0",
|
| 9 |
+
torch_dtype=torch.float16,
|
| 10 |
+
revision="fp16",
|
| 11 |
+
safety_checker=None
|
| 12 |
+
).to("cuda" if torch.cuda.is_available() else "cpu")
|
| 13 |
|
|
|
|
| 14 |
def generate_thumbnail(prompt):
|
| 15 |
+
image = pipe(prompt, height=512, width=512).images[0]
|
| 16 |
return image
|
| 17 |
|
| 18 |
# Gradio UI
|
| 19 |
+
iface = gr.Interface(
|
| 20 |
fn=generate_thumbnail,
|
| 21 |
+
inputs=gr.Textbox(label="Thumbnail Prompt"),
|
| 22 |
+
outputs=gr.Image(label="Generated Thumbnail"),
|
| 23 |
+
title="Anime Thumbnail Generator",
|
| 24 |
+
description="Generate thumbnails using Linaqruf/anything-v3.0 model"
|
| 25 |
+
)
|
| 26 |
+
|
| 27 |
+
iface.launch()
|