Spaces:
Runtime error
Runtime error
File size: 873 Bytes
31b8a10 69290b8 5e67317 31b8a10 9b58f9d 8d0dc10 efc8bb8 d5a417b 435181a d5a417b a7f0b14 8d0dc10 a7f0b14 cab84da 9b58f9d a7f0b14 9b58f9d cab84da |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 |
import gradio as gr
from diffusers import StableDiffusionPipeline, DPMSolverMultistepScheduler
import torch
model_id = "Fazzie/PokemonGAI"
device = "cuda" if torch.cuda.is_available() else "cpu"
pipe = StableDiffusionPipeline.from_pretrained(model_id, torch_dtype=torch.float32)
pipe.scheduler = DPMSolverMultistepScheduler.from_config(pipe.scheduler.config)
print("load model successfully!")
pipe = pipe.to(device)
def imagen(inputs):
prompt = inputs
negative_prompt = 'pixelated, distorted'
print("start inference")
image = pipe(prompt=inputs, negative_prompt=negative_prompt).images[0]
print("finish inference!")
return image
demo = gr.Interface(fn=imagen, inputs=[gr.Textbox(label = 'Prompt')], outputs="image")
if __name__ == "__main__":
demo.launch()
image.save("1.png")
# gr.Interface.load("models/Fazzie/PokemonGAI").launch() |