File size: 954 Bytes
f062bf5 f6651c9 f062bf5 cb75084 f6651c9 df9097e 2b0c959 7a9d092 b04b565 7a9d092 cc6e952 e69c6d4 352ce59 7f7b109 f6651c9 cc6e952 7ca5873 7a9d092 3f312a9 1bbf70e 9631ccf d3b1876 cc6e952 f6651c9 cb75084 2b0c959 |
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 |
# ==============================
# Program
# ==============================
import spaces
import os
import gradio as gr
import torch
from diffusers import DiffusionPipeline, StableDiffusionPipeline, StableDiffusionImg2ImgPipeline
pipe = StableDiffusionPipeline.from_pretrained("mswhite/graffiti_model", torch_dtype=torch.float16) #, safety_checker=None)
pipe = pipe.to("cuda")
pipe.safety_checker = lambda images, **kwargs: (images, [False] * len(images))
@spaces.GPU
def legoize(text):
prompt = "brit_graf " + text
return pipe(prompt).images[0]
with gr.Blocks() as demo:
gr.Markdown("<img src=https://huggingface.co/spaces/mswhite/Graffiti/resolve/main/0071.jpg width=720px>")
output = gr.Image(label="Output", width=720)
art_to_draw = gr.Textbox(label="Prompt to Draw: e.g. ")
flashb_btn = gr.Button("Spray Paint the Wall")
flashb_btn.click(fn=legoize, inputs=[art_to_draw], outputs=[output])
demo.launch()
|