File size: 2,200 Bytes
0d02199
 
 
 
 
 
 
74defa2
bae50d8
74defa2
0d02199
ef974d4
bae50d8
0d02199
ef974d4
bae50d8
0d02199
 
d98f006
36ff355
d98f006
0d02199
 
49696e1
0d02199
d98f006
 
 
 
0d02199
1a99d03
86968fe
0d02199
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
from PIL import Image
import gradio as gr
import torch, os, random
from accelerate import Accelerator
from transformers import pipeline
from diffusers.utils import load_image
from diffusers import DiffusionPipeline, DDPMScheduler
from diffusers import WuerstchenDecoderPipeline, WuerstchenPriorPipeline
from diffusers.pipelines.wuerstchen import DEFAULT_STAGE_C_TIMESTEPS

accelerator = Accelerator(cpu=True)
warp_prior = accelerator.prepare(WuerstchenPriorPipeline.from_pretrained("warp-ai/wuerstchen-prior", torch_dtype=torch.float32, use_safetensors=True, safety_cheker=None))
###warp_prior.scheduler = DDPMWuerstchenScheduler.from_config(warp_prior.scheduler.config)
warp_prior = warp_prior.to("cpu")
warp = accelerator.prepare(WuerstchenDecoderPipeline.from_pretrained("warp-ai/wuerstchen", torch_dtype=torch.float32, use_safetensors=True, safety_checker=None))
###warp.scheduler = DDPMWuerstchenScheduler.from_config(warp.scheduler.config)
warp = warp.to("cpu")
generator = torch.Generator(device="cpu").manual_seed(random.randint(1, 4876364))
apol=[]
def plex(cook, one, two):
    apol=[]
    ###goof = load_image(img).resize((512, 512))
    negative_prompt = "lowres,text,bad quality,low quality,jpeg artifacts,ugly,bad hands,bad face,blurry,bad eyes,watermark,signature"
    warp_out = warp_prior(prompt=cook, height=512,width=512,negative_prompt=negative_prompt,guidance_scale=two,timestep=DEFAULT_STAGE_C_TIMESTEPS,num_inference_steps=one)
    primpt = ""
    imas = warp(image_embeddings=warp_out.image_embeddings, height=512, width=512, num_inference_steps=one, timestep=DEFAULT_STAGE_C_TIMESTEPS,prompt=cook,negative_prompt=primpt,guidance_scale=0.0,output_type="pil")
    for i, igs in enumerate(imas["images"]):
        apol.append(igs)
    return apol

iface = gr.Interface(fn=plex,inputs=[gr.Textbox(label="prompt"), gr.Slider(label="Inference steps",minimum=1,step=1,maximum=10,value=5), gr.Slider(label="Prior guidance scale",minimum=4.1,step=0.1,maximum=19.9,value=4.1)],outputs=gr.Gallery(label="Generated Output Image",columns=2), title="Txt2Img Wrstchn SD", description="Very slow! Running on cpu. By JoPmt.")
iface.queue(max_size=1,api_open=False)
iface.launch(max_threads=1)