test-private-2 / app.py
chris-rannou's picture
chris-rannou HF Staff
Update app.py
0cac202 verified
raw
history blame
833 Bytes
""" App
"""
import gradio as gr
import time
import os
import torch
import spaces
from diffusers import StableDiffusionInstructPix2PixPipeline, EulerAncestralDiscreteScheduler
from diffusers.utils import load_image
device = "cuda" if torch.cuda.is_available() else "cpu"
model_repo_id = "timbrooks/instruct-pix2pix"
if torch.cuda.is_available():
torch_dtype = torch.float16
else:
torch_dtype = torch.float32
pipe = StableDiffusionInstructPix2PixPipeline.from_pretrained(
model_repo_id,
torch_dtype=torch_dtype,
safety_checker=None
)
pipe = pipe.to(device)
pipe.scheduler = EulerAncestralDiscreteScheduler.from_config(pipe.scheduler.config)
@spaces.GPU
def greet(name):
return "Hello there {}".format(name)
# comment updated 2
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
iface.launch()