File size: 1,119 Bytes
4c81f4e
f062bf5
b2be707
f062bf5
cb75084
d456435
df9097e
2b0c959
7a9d092
b04b565
7a9d092
7f7b109
 
92920e1
e69c6d4
352ce59
7f7b109
aa4abd7
e63886e
 
7ca5873
7a9d092
3f312a9
 
 
 
e63886e
d849abe
d3b1876
e63886e
 
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

# ==============================
# Main Code
# ==============================

import spaces
import os
import gradio as gr
import torch
from diffusers import DiffusionPipeline, StableDiffusionPipeline, StableDiffusionImg2ImgPipeline

# Nvidia GPU config

pipe = StableDiffusionPipeline.from_pretrained("mswhite/manga_model", torch_dtype=torch.float16) #, safety_checker=None)
pipe = pipe.to("cuda")
pipe.safety_checker = lambda images, **kwargs: (images, [False] * len(images))

@spaces.GPU                              # decorator to use ZeroGPU instance - comment out to use other GPUs
def infer_diffusion(text):
    prompt = "nik_mag" + text
    return pipe(prompt).images[0]

# Mobile Version of Blocks

with gr.Blocks() as demo:
    
  gr.Markdown("<img src=https://huggingface.co/spaces/mswhite/Nik/resolve/main/logo.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("Generate A New Manga Character")
  flashb_btn.click(fn=infer_diffusion, inputs=[art_to_draw], outputs=[output]) 

demo.launch()