Spaces:
Running
Running
import spaces | |
import torch | |
import gradio as gr | |
from gradio import processing_utils, utils | |
from PIL import Image | |
import random | |
from diffusers import ( | |
DiffusionPipeline, | |
AutoencoderKL, | |
StableDiffusionControlNetPipeline, | |
ControlNetModel, | |
StableDiffusionLatentUpscalePipeline, | |
StableDiffusionImg2ImgPipeline, | |
StableDiffusionControlNetImg2ImgPipeline, | |
DPMSolverMultistepScheduler, # <-- Added import | |
EulerDiscreteScheduler # <-- Added import | |
) | |
import tempfile | |
import time | |
from share_btn import community_icon_html, loading_icon_html, share_js | |
import user_history | |
from illusion_style import css | |
BASE_MODEL = "SG161222/Realistic_Vision_V5.1_noVAE" | |
if torch.cuda.is_available(): | |
device='gpu' | |
else: | |
device='cpu' | |
# Initialize both pipelines | |
vae = AutoencoderKL.from_pretrained("stabilityai/sd-vae-ft-mse", torch_dtype=torch.float16) | |
#init_pipe = DiffusionPipeline.from_pretrained("SG161222/Realistic_Vision_V5.1_noVAE", torch_dtype=torch.float16) | |
controlnet = ControlNetModel.from_pretrained("monster-labs/control_v1p_sd15_qrcode_monster", torch_dtype=torch.float16)#, torch_dtype=torch.float16) | |
main_pipe = StableDiffusionControlNetPipeline.from_pretrained( | |
BASE_MODEL, | |
controlnet=controlnet, | |
vae=vae, | |
safety_checker=None, | |
torch_dtype=torch.float16, | |
).to(device) | |
def greet(name): | |
return "Hello " + name + "!!" | |
demo = gr.Interface(fn=greet, inputs="text", outputs="text") | |
demo.launch() |