Spaces:
Runtime error
Runtime error
lzyhha
commited on
Commit
·
b924914
1
Parent(s):
7221a6f
space
Browse files- app.py +2 -3
- visualcloze.py +2 -1
app.py
CHANGED
|
@@ -1,10 +1,9 @@
|
|
| 1 |
import argparse
|
| 2 |
-
import
|
| 3 |
import gradio as gr
|
| 4 |
import demo_tasks
|
| 5 |
from functools import partial
|
| 6 |
from data.prefix_instruction import get_layout_instruction
|
| 7 |
-
from visualcloze import VisualClozeModel
|
| 8 |
from huggingface_hub import snapshot_download
|
| 9 |
|
| 10 |
|
|
@@ -306,7 +305,6 @@ def create_demo(model):
|
|
| 306 |
updates.append(gr.update(elem_id="layout_prompt", value=get_layout_instruction(w, actual_h)))
|
| 307 |
return updates
|
| 308 |
|
| 309 |
-
@spaces.GPU
|
| 310 |
def generate_image(*inputs):
|
| 311 |
images = []
|
| 312 |
for i in range(model.grid_h):
|
|
@@ -467,6 +465,7 @@ def parse_args():
|
|
| 467 |
parser.add_argument("--resolution", type=int, default=384)
|
| 468 |
return parser.parse_args()
|
| 469 |
|
|
|
|
| 470 |
if __name__ == "__main__":
|
| 471 |
args = parse_args()
|
| 472 |
|
|
|
|
| 1 |
import argparse
|
| 2 |
+
from visualcloze import VisualClozeModel
|
| 3 |
import gradio as gr
|
| 4 |
import demo_tasks
|
| 5 |
from functools import partial
|
| 6 |
from data.prefix_instruction import get_layout_instruction
|
|
|
|
| 7 |
from huggingface_hub import snapshot_download
|
| 8 |
|
| 9 |
|
|
|
|
| 305 |
updates.append(gr.update(elem_id="layout_prompt", value=get_layout_instruction(w, actual_h)))
|
| 306 |
return updates
|
| 307 |
|
|
|
|
| 308 |
def generate_image(*inputs):
|
| 309 |
images = []
|
| 310 |
for i in range(model.grid_h):
|
|
|
|
| 465 |
parser.add_argument("--resolution", type=int, default=384)
|
| 466 |
return parser.parse_args()
|
| 467 |
|
| 468 |
+
|
| 469 |
if __name__ == "__main__":
|
| 470 |
args = parse_args()
|
| 471 |
|
visualcloze.py
CHANGED
|
@@ -1,5 +1,6 @@
|
|
| 1 |
|
| 2 |
import random
|
|
|
|
| 3 |
from einops import rearrange
|
| 4 |
from diffusers.models import AutoencoderKL
|
| 5 |
from PIL import Image
|
|
@@ -12,7 +13,6 @@ from flux.util import load_clip, load_t5, load_flow_model
|
|
| 12 |
from transport import Sampler, create_transport
|
| 13 |
from imgproc import to_rgb_if_rgba
|
| 14 |
|
| 15 |
-
|
| 16 |
def center_crop(image, target_size):
|
| 17 |
width, height = image.size
|
| 18 |
new_width, new_height = target_size
|
|
@@ -75,6 +75,7 @@ def resize_with_aspect_ratio(img, resolution, divisible=16, aspect_ratio=None):
|
|
| 75 |
return img.resize((new_w, new_h), Image.LANCZOS)
|
| 76 |
|
| 77 |
|
|
|
|
| 78 |
class VisualClozeModel:
|
| 79 |
def __init__(
|
| 80 |
self, model_path, model_name="flux-dev-fill-lora", max_length=512, lora_rank=256,
|
|
|
|
| 1 |
|
| 2 |
import random
|
| 3 |
+
import spaces
|
| 4 |
from einops import rearrange
|
| 5 |
from diffusers.models import AutoencoderKL
|
| 6 |
from PIL import Image
|
|
|
|
| 13 |
from transport import Sampler, create_transport
|
| 14 |
from imgproc import to_rgb_if_rgba
|
| 15 |
|
|
|
|
| 16 |
def center_crop(image, target_size):
|
| 17 |
width, height = image.size
|
| 18 |
new_width, new_height = target_size
|
|
|
|
| 75 |
return img.resize((new_w, new_h), Image.LANCZOS)
|
| 76 |
|
| 77 |
|
| 78 |
+
@spaces.GPU
|
| 79 |
class VisualClozeModel:
|
| 80 |
def __init__(
|
| 81 |
self, model_path, model_name="flux-dev-fill-lora", max_length=512, lora_rank=256,
|