Spaces:
Sleeping
Sleeping
Rajeev-86
commited on
Commit
·
cb52939
1
Parent(s):
fc76951
added paths in sync_to_hf.yml file to have HuggingFace trigger only when changes happens to these paths and added api-test.py.
Browse files- .github/workflows/sync_to_hf.yml +6 -1
- .gitignore +1 -0
- api-test.py +25 -0
.github/workflows/sync_to_hf.yml
CHANGED
|
@@ -2,7 +2,12 @@ name: Sync to Hugging Face Hub
|
|
| 2 |
|
| 3 |
on:
|
| 4 |
push:
|
| 5 |
-
branches: [main]
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 6 |
workflow_dispatch: # Allows manual trigger from the Actions tab
|
| 7 |
|
| 8 |
jobs:
|
|
|
|
| 2 |
|
| 3 |
on:
|
| 4 |
push:
|
| 5 |
+
branches: [main]
|
| 6 |
+
paths:
|
| 7 |
+
- 'Dockerfile'
|
| 8 |
+
- 'requirements.txt'
|
| 9 |
+
- 'README.md'
|
| 10 |
+
- '.github/workflows/sync_to_hf.yml'
|
| 11 |
workflow_dispatch: # Allows manual trigger from the Actions tab
|
| 12 |
|
| 13 |
jobs:
|
.gitignore
CHANGED
|
@@ -1,3 +1,4 @@
|
|
| 1 |
venv/
|
| 2 |
env/
|
| 3 |
__pycache__/
|
|
|
|
|
|
| 1 |
venv/
|
| 2 |
env/
|
| 3 |
__pycache__/
|
| 4 |
+
.vscode
|
api-test.py
ADDED
|
@@ -0,0 +1,25 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
import requests
|
| 2 |
+
import base64
|
| 3 |
+
import json
|
| 4 |
+
|
| 5 |
+
SPACE_URL = "https://Rexy-3d-Denoiser-Server.hf.space"
|
| 6 |
+
MODEL_NAME = "model_unet" # possible values: model_unet, model_runet, model_arunet
|
| 7 |
+
INPUT_FILE_PATH = "input.png"
|
| 8 |
+
OUTPUT_FILE_PATH = "output.png"
|
| 9 |
+
|
| 10 |
+
url = f"{SPACE_URL}/predictions/{MODEL_NAME}"
|
| 11 |
+
print(f"Sending request to {url} with file {INPUT_FILE_PATH}...")
|
| 12 |
+
with open(INPUT_FILE_PATH, "rb") as f:
|
| 13 |
+
response = requests.post(url, data=f)
|
| 14 |
+
|
| 15 |
+
# Check for success
|
| 16 |
+
response.raise_for_status()
|
| 17 |
+
|
| 18 |
+
# Try to save the output as a file (assume binary image, like curl)
|
| 19 |
+
try:
|
| 20 |
+
with open(OUTPUT_FILE_PATH, "wb") as out:
|
| 21 |
+
out.write(response.content)
|
| 22 |
+
print(f"\n Success! Denoised image saved to {OUTPUT_FILE_PATH}")
|
| 23 |
+
except Exception as e:
|
| 24 |
+
print(f"\n Error saving output: {e}")
|
| 25 |
+
print(f"Raw response content: {response.content[:500]}...")
|