Spaces:
Configuration error
Configuration error
Create app.py
Browse files
app.py
ADDED
|
@@ -0,0 +1,33 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import gradio as gr
|
| 2 |
+
from diffusers import StableDiffusionPipeline
|
| 3 |
+
import torch
|
| 4 |
+
|
| 5 |
+
# Modello Hugging Face per tatuaggi
|
| 6 |
+
MODEL_ID = "lllyasviel/control_v11p_sd15_lineart"
|
| 7 |
+
|
| 8 |
+
# Caricamento modello
|
| 9 |
+
pipe = StableDiffusionPipeline.from_pretrained(
|
| 10 |
+
MODEL_ID,
|
| 11 |
+
torch_dtype=torch.float16
|
| 12 |
+
)
|
| 13 |
+
|
| 14 |
+
# Se hai GPU, puoi usare: pipe.to("cuda")
|
| 15 |
+
pipe.to("cpu")
|
| 16 |
+
|
| 17 |
+
# Funzione per generare tatuaggi
|
| 18 |
+
def generate_tattoo(prompt):
|
| 19 |
+
final_prompt = f"{prompt}, clean lineart, tattoo style, black ink, detailed, high contrast"
|
| 20 |
+
image = pipe(final_prompt).images[0]
|
| 21 |
+
return image
|
| 22 |
+
|
| 23 |
+
# Interfaccia Gradio
|
| 24 |
+
interface = gr.Interface(
|
| 25 |
+
fn=generate_tattoo,
|
| 26 |
+
inputs=gr.Textbox(label="Write your tattoo idea"),
|
| 27 |
+
outputs="image",
|
| 28 |
+
title="AI Tattoo Generator",
|
| 29 |
+
description="Generate custom tattoo designs using AI. Write your idea and get a unique tattoo."
|
| 30 |
+
)
|
| 31 |
+
|
| 32 |
+
# Avvio app
|
| 33 |
+
interface.launch()
|