Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,6 +1,32 @@
|
|
1 |
import gradio as gr
|
|
|
|
|
|
|
2 |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
3 |
|
4 |
-
|
|
|
|
|
|
|
5 |
|
6 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
import gradio as gr
|
2 |
+
from diffusers import DiffusionPipeline, StableDiffusionXLImg2ImgPipeline
|
3 |
+
import torch
|
4 |
+
from PIL import Image
|
5 |
|
6 |
+
# Load the pipeline
|
7 |
+
prj_path = "jkcg/furniture-chair"
|
8 |
+
model = "stabilityai/stable-diffusion-xl-base-1.0"
|
9 |
+
pipe = DiffusionPipeline.from_pretrained(
|
10 |
+
model,
|
11 |
+
torch_dtype=torch.float16,
|
12 |
+
)
|
13 |
+
pipe.to("cuda")
|
14 |
+
pipe.load_lora_weights(prj_path, weight_name="pytorch_lora_weights.safetensors")
|
15 |
|
16 |
+
def generate_image(prompt, seed):
|
17 |
+
generator = torch.Generator("cuda").manual_seed(seed)
|
18 |
+
image = pipe(prompt=prompt, generator=generator).images[0]
|
19 |
+
return image
|
20 |
|
21 |
+
# Create the Gradio interface
|
22 |
+
interface = gr.Interface(
|
23 |
+
fn=generate_image,
|
24 |
+
inputs=[
|
25 |
+
gr.Textbox(label="Prompt", value="photo of a furnichair-texx in an empty room"),
|
26 |
+
gr.Slider(label="Seed", minimum=0, maximum=10000, step=1, value=42)
|
27 |
+
],
|
28 |
+
outputs=gr.Image(label="Generated Image")
|
29 |
+
)
|
30 |
+
|
31 |
+
# Launch the interface
|
32 |
+
interface.launch(share=True)
|