Spaces:
Running
on
Zero
Running
on
Zero
Commit
·
fd82537
1
Parent(s):
1792b56
Remove redundant codes in fixing the HF space permission error.
Browse files
app.py
CHANGED
|
@@ -18,11 +18,9 @@ import zipfile
|
|
| 18 |
|
| 19 |
|
| 20 |
hf_cache_path = '/tmp/hf_cache'
|
| 21 |
-
os.environ["HUGGINGFACE_HUB_CACHE"] = hf_cache_path
|
| 22 |
os.environ["HF_HOME"] = hf_cache_path
|
| 23 |
-
os.environ["
|
| 24 |
-
os.
|
| 25 |
-
os.makedirs(os.path.join("/tmp/hf_cache", "modules"), exist_ok=True)
|
| 26 |
|
| 27 |
import transformers
|
| 28 |
transformers.utils.move_cache()
|
|
@@ -99,7 +97,7 @@ usage_to_weights_file = {
|
|
| 99 |
'General-dynamic': 'BiRefNet_dynamic',
|
| 100 |
}
|
| 101 |
|
| 102 |
-
birefnet = transformers.AutoModelForImageSegmentation.from_pretrained('/'.join(('zhengpeng7', usage_to_weights_file['General'])), trust_remote_code=True
|
| 103 |
birefnet.to(device)
|
| 104 |
birefnet.eval(); birefnet.half()
|
| 105 |
|
|
@@ -112,7 +110,7 @@ def predict(images, resolution, weights_file):
|
|
| 112 |
# Load BiRefNet with chosen weights
|
| 113 |
_weights_file = '/'.join(('zhengpeng7', usage_to_weights_file[weights_file] if weights_file is not None else usage_to_weights_file['General']))
|
| 114 |
print('Using weights: {}.'.format(_weights_file))
|
| 115 |
-
birefnet = transformers.AutoModelForImageSegmentation.from_pretrained(_weights_file, trust_remote_code=True
|
| 116 |
birefnet.to(device)
|
| 117 |
birefnet.eval(); birefnet.half()
|
| 118 |
|
|
|
|
| 18 |
|
| 19 |
|
| 20 |
hf_cache_path = '/tmp/hf_cache'
|
|
|
|
| 21 |
os.environ["HF_HOME"] = hf_cache_path
|
| 22 |
+
# os.environ["HF_MODULES_CACHE"] = os.path.join("/tmp/hf_cache", "modules")
|
| 23 |
+
os.makedirs(os.path.join(hf_cache_path, "modules"), exist_ok=True)
|
|
|
|
| 24 |
|
| 25 |
import transformers
|
| 26 |
transformers.utils.move_cache()
|
|
|
|
| 97 |
'General-dynamic': 'BiRefNet_dynamic',
|
| 98 |
}
|
| 99 |
|
| 100 |
+
birefnet = transformers.AutoModelForImageSegmentation.from_pretrained('/'.join(('zhengpeng7', usage_to_weights_file['General'])), trust_remote_code=True)
|
| 101 |
birefnet.to(device)
|
| 102 |
birefnet.eval(); birefnet.half()
|
| 103 |
|
|
|
|
| 110 |
# Load BiRefNet with chosen weights
|
| 111 |
_weights_file = '/'.join(('zhengpeng7', usage_to_weights_file[weights_file] if weights_file is not None else usage_to_weights_file['General']))
|
| 112 |
print('Using weights: {}.'.format(_weights_file))
|
| 113 |
+
birefnet = transformers.AutoModelForImageSegmentation.from_pretrained(_weights_file, trust_remote_code=True)
|
| 114 |
birefnet.to(device)
|
| 115 |
birefnet.eval(); birefnet.half()
|
| 116 |
|