Spaces:
Sleeping
Sleeping
Update app.py
Browse files
app.py
CHANGED
|
@@ -22,24 +22,24 @@ REPO_NAME = "jaydatech/phi3-finetuned-project"
|
|
| 22 |
BASE_MODEL = "microsoft/Phi-3-mini-4k-instruct"
|
| 23 |
HF_TOKEN = os.getenv("HF_TOKEN") # Load from Render environment variable
|
| 24 |
|
| 25 |
-
# Optional: Cleanup if corrupted config is detected
|
| 26 |
-
def check_and_cleanup_corrupt_cache(repo_name: str):
|
| 27 |
-
|
| 28 |
-
|
| 29 |
-
|
| 30 |
-
|
| 31 |
-
|
| 32 |
-
|
| 33 |
-
|
| 34 |
-
|
| 35 |
-
|
| 36 |
-
|
| 37 |
-
|
| 38 |
-
|
| 39 |
-
|
| 40 |
-
|
| 41 |
-
|
| 42 |
-
check_and_cleanup_corrupt_cache(REPO_NAME)
|
| 43 |
|
| 44 |
app = FastAPI()
|
| 45 |
|
|
|
|
| 22 |
BASE_MODEL = "microsoft/Phi-3-mini-4k-instruct"
|
| 23 |
HF_TOKEN = os.getenv("HF_TOKEN") # Load from Render environment variable
|
| 24 |
|
| 25 |
+
# # Optional: Cleanup if corrupted config is detected
|
| 26 |
+
# def check_and_cleanup_corrupt_cache(repo_name: str):
|
| 27 |
+
# cache_dir = os.environ["HF_HOME"]
|
| 28 |
+
# model_dir = os.path.join(cache_dir, f"models--{repo_name.replace('/', '--')}")
|
| 29 |
+
# if os.path.exists(model_dir):
|
| 30 |
+
# for root, dirs, files in os.walk(model_dir):
|
| 31 |
+
# for file in files:
|
| 32 |
+
# if file == "config.json":
|
| 33 |
+
# path = os.path.join(root, file)
|
| 34 |
+
# try:
|
| 35 |
+
# with open(path, "r") as f:
|
| 36 |
+
# json.load(f)
|
| 37 |
+
# except json.JSONDecodeError:
|
| 38 |
+
# print(f"Corrupted config file detected at {path}, cleaning up...")
|
| 39 |
+
# shutil.rmtree(model_dir, ignore_errors=True)
|
| 40 |
+
# return
|
| 41 |
+
|
| 42 |
+
# check_and_cleanup_corrupt_cache(REPO_NAME)
|
| 43 |
|
| 44 |
app = FastAPI()
|
| 45 |
|