Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -4,11 +4,13 @@ import random
|
|
| 4 |
import spaces
|
| 5 |
import torch
|
| 6 |
from diffusers import DiffusionPipeline
|
|
|
|
| 7 |
|
| 8 |
dtype = torch.bfloat16
|
| 9 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 10 |
|
| 11 |
pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16).to(device)
|
|
|
|
| 12 |
|
| 13 |
#pipeline2Image = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0", torch_dtypes=torch.bfloat16).to("cpu")
|
| 14 |
|
|
@@ -29,6 +31,11 @@ def infer(prompt, seed=42, randomize_seed=False, width=1024, height=1024, guidan
|
|
| 29 |
generator=generator,
|
| 30 |
guidance_scale=guidance_scale
|
| 31 |
).images[0]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 32 |
return image, seed
|
| 33 |
|
| 34 |
examples = [
|
|
@@ -63,7 +70,7 @@ with gr.Blocks(css=css) as demo:
|
|
| 63 |
)
|
| 64 |
|
| 65 |
run_button = gr.Button("Run", scale=0)
|
| 66 |
-
|
| 67 |
result = gr.Image(label="Result", show_label=False)
|
| 68 |
|
| 69 |
with gr.Accordion("Advanced Settings", open=False):
|
|
|
|
| 4 |
import spaces
|
| 5 |
import torch
|
| 6 |
from diffusers import DiffusionPipeline
|
| 7 |
+
from huggingface_hub import InferenceClient
|
| 8 |
|
| 9 |
dtype = torch.bfloat16
|
| 10 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
| 11 |
|
| 12 |
pipe = DiffusionPipeline.from_pretrained("black-forest-labs/FLUX.1-dev", torch_dtype=torch.bfloat16).to(device)
|
| 13 |
+
sdxl = InferenceClient(model="stabilityai/stable-diffusion-xl-base-1.0", token=os.environ['HF_TOKEN'])
|
| 14 |
|
| 15 |
#pipeline2Image = DiffusionPipeline.from_pretrained("stabilityai/stable-diffusion-xl-refiner-1.0", torch_dtypes=torch.bfloat16).to("cpu")
|
| 16 |
|
|
|
|
| 31 |
generator=generator,
|
| 32 |
guidance_scale=guidance_scale
|
| 33 |
).images[0]
|
| 34 |
+
image = sdxl.text_to_image(
|
| 35 |
+
"Dark gothic city in a misty night, lit by street lamps. A man in a cape is walking away from us",
|
| 36 |
+
guidance_scale=9, num_inference_steps=50
|
| 37 |
+
)
|
| 38 |
+
|
| 39 |
return image, seed
|
| 40 |
|
| 41 |
examples = [
|
|
|
|
| 70 |
)
|
| 71 |
|
| 72 |
run_button = gr.Button("Run", scale=0)
|
| 73 |
+
|
| 74 |
result = gr.Image(label="Result", show_label=False)
|
| 75 |
|
| 76 |
with gr.Accordion("Advanced Settings", open=False):
|