|
import gradio as gr |
|
import requests |
|
import os |
|
from PIL import Image |
|
from io import BytesIO |
|
|
|
|
|
repo = "artificialguybr/StudioGhibli.Redmond-V2" |
|
trigger_word = "Studio Ghibli, StdGBRedmAF" |
|
|
|
|
|
def generate_image(prompt): |
|
api_url = f"https://api-inference.huggingface.co/models/{repo}" |
|
|
|
headers = { |
|
|
|
} |
|
payload = { |
|
"inputs": f"{prompt} {trigger_word}", |
|
"parameters": { |
|
"negative_prompt": "bad art, ugly, watermark, deformed", |
|
"num_inference_steps": 30, |
|
"scheduler": "DPMSolverMultistepScheduler" |
|
}, |
|
} |
|
|
|
response = requests.post(api_url, headers=headers, json=payload) |
|
response.raise_for_status() |
|
image_data = response.json().get("data", [])[0] |
|
|
|
|
|
return Image.open(BytesIO(image_data)) |
|
|
|
|
|
iface = gr.Interface( |
|
fn=generate_image, |
|
inputs=gr.inputs.Textbox(lines=2, placeholder="Digite seu prompt aqui..."), |
|
outputs="image", |
|
title="Gerador de Imagens Studio Ghibli V2", |
|
description="Insira um prompt de texto para gerar uma imagem com o estilo do Studio Ghibli." |
|
) |
|
|
|
|
|
iface.launch() |