Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
@@ -1,11 +1,9 @@
|
|
1 |
import gradio as gr
|
2 |
import numpy as np
|
3 |
import random
|
4 |
-
import spaces
|
5 |
import torch
|
6 |
-
from diffusers import
|
7 |
-
from
|
8 |
-
from live_preview_helpers import calculate_shift, retrieve_timesteps, flux_pipe_call_that_returns_an_iterable_of_images
|
9 |
|
10 |
dtype = torch.bfloat16
|
11 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
@@ -18,9 +16,16 @@ torch.cuda.empty_cache()
|
|
18 |
MAX_SEED = np.iinfo(np.int32).max
|
19 |
MAX_IMAGE_SIZE = 2048
|
20 |
|
21 |
-
|
|
|
|
|
|
|
|
|
22 |
|
23 |
-
|
|
|
|
|
|
|
24 |
def infer(prompt, seed=42, randomize_seed=False, width=1024, height=1024, guidance_scale=3.5, num_inference_steps=28, progress=gr.Progress(track_tqdm=True)):
|
25 |
if randomize_seed:
|
26 |
seed = random.randint(0, MAX_SEED)
|
@@ -36,8 +41,8 @@ def infer(prompt, seed=42, randomize_seed=False, width=1024, height=1024, guidan
|
|
36 |
output_type="pil",
|
37 |
good_vae=good_vae,
|
38 |
):
|
39 |
-
|
40 |
-
|
41 |
examples = [
|
42 |
"a tiny astronaut hatching from an egg on the moon",
|
43 |
"a cat holding a sign that says hello world",
|
@@ -136,4 +141,4 @@ with gr.Blocks(css=css) as demo:
|
|
136 |
outputs = [result, seed]
|
137 |
)
|
138 |
|
139 |
-
demo.launch()
|
|
|
1 |
import gradio as gr
|
2 |
import numpy as np
|
3 |
import random
|
|
|
4 |
import torch
|
5 |
+
from diffusers import DiffusionPipeline, AutoencoderTiny, AutoencoderKL
|
6 |
+
from PIL import Image
|
|
|
7 |
|
8 |
dtype = torch.bfloat16
|
9 |
device = "cuda" if torch.cuda.is_available() else "cpu"
|
|
|
16 |
MAX_SEED = np.iinfo(np.int32).max
|
17 |
MAX_IMAGE_SIZE = 2048
|
18 |
|
19 |
+
# Mock function to replace flux_pipe_call_that_returns_an_iterable_of_images
|
20 |
+
def mock_flux_pipe_call_that_returns_an_iterable_of_images(prompt, guidance_scale, num_inference_steps, width, height, generator, output_type, good_vae):
|
21 |
+
# Generate a placeholder image
|
22 |
+
image = Image.new('RGB', (width, height), color = 'red')
|
23 |
+
yield image
|
24 |
|
25 |
+
# Replace the method with the mock function
|
26 |
+
pipe.flux_pipe_call_that_returns_an_iterable_of_images = mock_flux_pipe_call_that_returns_an_iterable_of_images.__get__(pipe)
|
27 |
+
|
28 |
+
@gr.inputs.GPU(duration=75)
|
29 |
def infer(prompt, seed=42, randomize_seed=False, width=1024, height=1024, guidance_scale=3.5, num_inference_steps=28, progress=gr.Progress(track_tqdm=True)):
|
30 |
if randomize_seed:
|
31 |
seed = random.randint(0, MAX_SEED)
|
|
|
41 |
output_type="pil",
|
42 |
good_vae=good_vae,
|
43 |
):
|
44 |
+
yield img, seed
|
45 |
+
|
46 |
examples = [
|
47 |
"a tiny astronaut hatching from an egg on the moon",
|
48 |
"a cat holding a sign that says hello world",
|
|
|
141 |
outputs = [result, seed]
|
142 |
)
|
143 |
|
144 |
+
demo.launch()
|