Spaces:
Build error
Build error
Update app.py
Browse files
app.py
CHANGED
|
@@ -18,7 +18,7 @@ from utils import process_gradio_source, get_bbox_from_mask, crop_image_from_bb,
|
|
| 18 |
resize_img_and_pad, generate_context_reference_image
|
| 19 |
from huggingface_hub import snapshot_download
|
| 20 |
|
| 21 |
-
|
| 22 |
# Global settings.
|
| 23 |
with open(os.path.join(os.path.dirname(__file__), 'path_dict.json'), 'r') as f:
|
| 24 |
path_dict = json.load(f)
|
|
@@ -29,11 +29,14 @@ os.environ['TMPDIR'] = path_dict['gradio_temp_dir']
|
|
| 29 |
|
| 30 |
# Function of loading pre-trained models.
|
| 31 |
def load_models():
|
| 32 |
-
|
|
|
|
|
|
|
|
|
|
| 33 |
torch_dtype=torch.bfloat16)
|
| 34 |
-
pipe = CalligrapherPipeline.from_pretrained(
|
| 35 |
torch_dtype=torch.bfloat16).to("cuda")
|
| 36 |
-
model = Calligrapher(pipe,
|
| 37 |
return model
|
| 38 |
|
| 39 |
|
|
|
|
| 18 |
resize_img_and_pad, generate_context_reference_image
|
| 19 |
from huggingface_hub import snapshot_download
|
| 20 |
|
| 21 |
+
|
| 22 |
# Global settings.
|
| 23 |
with open(os.path.join(os.path.dirname(__file__), 'path_dict.json'), 'r') as f:
|
| 24 |
path_dict = json.load(f)
|
|
|
|
| 29 |
|
| 30 |
# Function of loading pre-trained models.
|
| 31 |
def load_models():
|
| 32 |
+
base_model_path = snapshot_download("black-forest-labs/FLUX.1-Fill-dev")
|
| 33 |
+
image_encoder_path = snapshot_download("google/siglip-so400m-patch14-384")
|
| 34 |
+
calligrapher_path = snapshot_download("Calligrapher2025/Calligrapher")
|
| 35 |
+
transformer = FluxTransformer2DModel.from_pretrained(base_model_path, subfolder="transformer",
|
| 36 |
torch_dtype=torch.bfloat16)
|
| 37 |
+
pipe = CalligrapherPipeline.from_pretrained(base_model_path, transformer=transformer,
|
| 38 |
torch_dtype=torch.bfloat16).to("cuda")
|
| 39 |
+
model = Calligrapher(pipe, image_encoder_path, calligrapher_path, device="cuda", num_tokens=128)
|
| 40 |
return model
|
| 41 |
|
| 42 |
|