Spaces:
Runtime error
Runtime error
Update app.py
Browse files
app.py
CHANGED
|
@@ -11,6 +11,7 @@ from peft import LoraConfig
|
|
| 11 |
from PIL import Image
|
| 12 |
from pipelines.flux_pipeline.pipeline import SynCDFluxPipeline
|
| 13 |
from pipelines.flux_pipeline.transformer import FluxTransformer2DModelWithMasking
|
|
|
|
| 14 |
|
| 15 |
HF_TOKEN = os.getenv('Syncd')
|
| 16 |
|
|
@@ -57,7 +58,12 @@ lora_config = LoraConfig(
|
|
| 57 |
target_modules=target_modules,
|
| 58 |
)
|
| 59 |
pipeline.transformer.add_adapter(lora_config)
|
| 60 |
-
finetuned_path = torch.load('models/pytorch_model.bin', map_location='cpu', weights_only=False)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 61 |
transformer_dict = {}
|
| 62 |
for key,value in finetuned_path.items():
|
| 63 |
if 'transformer.base_model.model.' in key:
|
|
|
|
| 11 |
from PIL import Image
|
| 12 |
from pipelines.flux_pipeline.pipeline import SynCDFluxPipeline
|
| 13 |
from pipelines.flux_pipeline.transformer import FluxTransformer2DModelWithMasking
|
| 14 |
+
from huggingface_hub import hf_hub_download
|
| 15 |
|
| 16 |
HF_TOKEN = os.getenv('Syncd')
|
| 17 |
|
|
|
|
| 58 |
target_modules=target_modules,
|
| 59 |
)
|
| 60 |
pipeline.transformer.add_adapter(lora_config)
|
| 61 |
+
#finetuned_path = torch.load('models/pytorch_model.bin', map_location='cpu', weights_only=False)
|
| 62 |
+
# Tự động tải file model chuẩn từ Repo gốc về
|
| 63 |
+
model_path = hf_hub_download(repo_id="nupurkmr9/SynCD", filename="models/pytorch_model.bin", repo_type="space")
|
| 64 |
+
|
| 65 |
+
# Load file vừa tải về
|
| 66 |
+
finetuned_path = torch.load(model_path, map_location='cpu', weights_only=False)
|
| 67 |
transformer_dict = {}
|
| 68 |
for key,value in finetuned_path.items():
|
| 69 |
if 'transformer.base_model.model.' in key:
|