Update app.py
Browse files
app.py
CHANGED
|
@@ -2,7 +2,6 @@ import gradio as gr
|
|
| 2 |
import torch
|
| 3 |
from diffusers import StableDiffusionXLPipeline, AutoencoderKL, KDPM2AncestralDiscreteScheduler
|
| 4 |
from huggingface_hub import hf_hub_download
|
| 5 |
-
import spaces
|
| 6 |
from PIL import Image
|
| 7 |
import requests
|
| 8 |
from translatepy import Translator
|
|
@@ -37,13 +36,12 @@ vae = AutoencoderKL.from_pretrained(
|
|
| 37 |
|
| 38 |
# Ensure model and scheduler are initialized in GPU-enabled function
|
| 39 |
if torch.cuda.is_available():
|
| 40 |
-
pipe = StableDiffusionXLPipeline.from_pretrained(model, vae=vae, torch_dtype=torch.float16).to(
|
| 41 |
|
| 42 |
pipe.scheduler = KDPM2AncestralDiscreteScheduler.from_config(pipe.scheduler.config)
|
| 43 |
|
| 44 |
|
| 45 |
# Function
|
| 46 |
-
@spaces.GPU()
|
| 47 |
def generate_image(
|
| 48 |
prompt,
|
| 49 |
negative="low quality",
|
|
@@ -92,7 +90,7 @@ with gr.Blocks(css=CSS, js=JS, theme="soft") as demo:
|
|
| 92 |
img = gr.Image(label='Mobius Generated Image')
|
| 93 |
with gr.Accordion("Advanced Options", open=False):
|
| 94 |
with gr.Row():
|
| 95 |
-
negative = gr.Textbox(label="Negative prompt", value="low quality")
|
| 96 |
with gr.Row():
|
| 97 |
width = gr.Slider(
|
| 98 |
label="Width",
|
|
|
|
| 2 |
import torch
|
| 3 |
from diffusers import StableDiffusionXLPipeline, AutoencoderKL, KDPM2AncestralDiscreteScheduler
|
| 4 |
from huggingface_hub import hf_hub_download
|
|
|
|
| 5 |
from PIL import Image
|
| 6 |
import requests
|
| 7 |
from translatepy import Translator
|
|
|
|
| 36 |
|
| 37 |
# Ensure model and scheduler are initialized in GPU-enabled function
|
| 38 |
if torch.cuda.is_available():
|
| 39 |
+
pipe = StableDiffusionXLPipeline.from_pretrained(model, vae=vae, torch_dtype=torch.float16).to(0)
|
| 40 |
|
| 41 |
pipe.scheduler = KDPM2AncestralDiscreteScheduler.from_config(pipe.scheduler.config)
|
| 42 |
|
| 43 |
|
| 44 |
# Function
|
|
|
|
| 45 |
def generate_image(
|
| 46 |
prompt,
|
| 47 |
negative="low quality",
|
|
|
|
| 90 |
img = gr.Image(label='Mobius Generated Image')
|
| 91 |
with gr.Accordion("Advanced Options", open=False):
|
| 92 |
with gr.Row():
|
| 93 |
+
negative = gr.Textbox(label="Negative prompt", value="low quality, ugly, blurry")
|
| 94 |
with gr.Row():
|
| 95 |
width = gr.Slider(
|
| 96 |
label="Width",
|