File size: 1,444 Bytes
4c81f4e f062bf5 a70795a f062bf5 cb75084 df9097e 545ce54 2b0c959 7a9d092 f062bf5 7a9d092 7f7b109 a94d07a d77102b 7f7b109 7a9d092 b62a1bd 4985cd1 f062bf5 cb75084 a70795a 2b0c959 49f7011 7ca5873 7a9d092 b62a1bd cb75084 3f312a9 a70795a 3f312a9 cb75084 2b0c959 784c5b6 |
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 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 |
# ==============================
# Main Code
# ==============================
import os
import spaces
import gradio as gr
import torch
from diffusers import StableDiffusionPipeline, StableDiffusionImg2ImgPipeline
# Nvidia GPU config
pipe = StableDiffusionPipeline.from_pretrained("mswhite/miamivice", torch_dtype=torch.float16) #, safety_checker=None)
pipe = pipe.to("cuda")
# Optional Img2Img pipeline
#pipe_img = StableDiffusionImg2ImgPipeline.from_pretrained("mswhite/miamivice", torch_dtype=torch.float16, safety_checker=None)
#pipe_img = pipe_img.to("cuda")
# Sample Prompt - "bright clean clear illustration side profile of a woman wearing pink lipstick p_nagel"
@spaces.GPU
def nagelize(text):
prompt = "p_nagel detailed illustration of " + text + " bright solid colors"
return pipe(prompt).images[0]
#def nagelize_me(source_image):
# prompt = "p_nagel"
# return pipe_img(prompt, image=source_image, strength=0.6, num_inference_steps=500, guidance_scale=40.0).images[0]
# Web Version of Blocks()
with gr.Blocks() as demo:
gr.Markdown("<img src=https://huggingface.co/spaces/mswhite/miamivice/resolve/main/miami.jpg width=720px>")
output = gr.Image(label="Output", width=720)
art_to_draw = gr.Textbox(label="Prompt to Draw: e.g. woman with red hair")
flashb_btn = gr.Button("Flashback to the 80s")
flashb_btn.click(fn=nagelize, inputs=[art_to_draw], outputs=[output])
demo.launch()
|