Spaces:
Sleeping
Sleeping
Dharini Baskaran
commited on
Commit
Β·
63642bb
1
Parent(s):
10bbab5
updating docker
Browse files
app.py
CHANGED
|
@@ -37,14 +37,15 @@ os.makedirs(OUTPUT_DIR, exist_ok=True)
|
|
| 37 |
if not os.path.exists(model_path):
|
| 38 |
print("π Model file not found! Downloading...")
|
| 39 |
try:
|
| 40 |
-
gdown.download(GDRIVE_URL, model_path, quiet=False)
|
|
|
|
| 41 |
print("β
Model downloaded successfully.")
|
| 42 |
except Exception as e:
|
| 43 |
print(f"β Failed to download model: {e}")
|
| 44 |
|
| 45 |
# Import model
|
| 46 |
sys.path.append(MODEL_DIR)
|
| 47 |
-
from rcnn_run import main, write_config
|
| 48 |
|
| 49 |
cfg = write_config()
|
| 50 |
|
|
@@ -55,14 +56,16 @@ cfg = write_config()
|
|
| 55 |
def predict(uploaded_file):
|
| 56 |
if uploaded_file is None:
|
| 57 |
return None, None, "No file uploaded."
|
| 58 |
-
|
|
|
|
|
|
|
| 59 |
# Save uploaded image
|
| 60 |
-
input_bytes = uploaded_file.read()
|
| 61 |
-
img = Image.open(BytesIO(input_bytes)).convert("RGB")
|
| 62 |
-
input_filename = uploaded_file.name
|
| 63 |
-
uploaded_path = os.path.join(UPLOAD_DIR, input_filename)
|
| 64 |
-
img.save(uploaded_path)
|
| 65 |
-
print(f"β
Image saved to {uploaded_path}")
|
| 66 |
|
| 67 |
# Prepare output paths
|
| 68 |
output_json_name = input_filename.replace(".png", "_result.json").replace(".jpg", "_result.json").replace(".jpeg", "_result.json")
|
|
@@ -92,7 +95,8 @@ with gr.Blocks() as demo:
|
|
| 92 |
|
| 93 |
with gr.Row():
|
| 94 |
with gr.Column():
|
| 95 |
-
uploaded_file = gr.File(label="Upload your Floorplan Image", type="
|
|
|
|
| 96 |
run_button = gr.Button("Run Vectorizer π₯")
|
| 97 |
|
| 98 |
with gr.Column():
|
|
|
|
| 37 |
if not os.path.exists(model_path):
|
| 38 |
print("π Model file not found! Downloading...")
|
| 39 |
try:
|
| 40 |
+
# gdown.download(GDRIVE_URL, model_path, quiet=False)
|
| 41 |
+
gdown.download(GDRIVE_URL, model_path, quiet=False, use_cookies=False)
|
| 42 |
print("β
Model downloaded successfully.")
|
| 43 |
except Exception as e:
|
| 44 |
print(f"β Failed to download model: {e}")
|
| 45 |
|
| 46 |
# Import model
|
| 47 |
sys.path.append(MODEL_DIR)
|
| 48 |
+
from rcnn_model.scripts.rcnn_run import main, write_config
|
| 49 |
|
| 50 |
cfg = write_config()
|
| 51 |
|
|
|
|
| 56 |
def predict(uploaded_file):
|
| 57 |
if uploaded_file is None:
|
| 58 |
return None, None, "No file uploaded."
|
| 59 |
+
uploaded_path = uploaded_file
|
| 60 |
+
input_filename = os.path.basename(uploaded_path)
|
| 61 |
+
print(f"β
Image received at {uploaded_path}")
|
| 62 |
# Save uploaded image
|
| 63 |
+
# input_bytes = uploaded_file.read()
|
| 64 |
+
# img = Image.open(BytesIO(input_bytes)).convert("RGB")
|
| 65 |
+
# input_filename = uploaded_file.name
|
| 66 |
+
# uploaded_path = os.path.join(UPLOAD_DIR, input_filename)
|
| 67 |
+
# img.save(uploaded_path)
|
| 68 |
+
# print(f"β
Image saved to {uploaded_path}")
|
| 69 |
|
| 70 |
# Prepare output paths
|
| 71 |
output_json_name = input_filename.replace(".png", "_result.json").replace(".jpg", "_result.json").replace(".jpeg", "_result.json")
|
|
|
|
| 95 |
|
| 96 |
with gr.Row():
|
| 97 |
with gr.Column():
|
| 98 |
+
uploaded_file = gr.File(label="Upload your Floorplan Image", type="filepath")
|
| 99 |
+
# uploaded_file = gr.File(label="Upload your Floorplan Image", type="file")
|
| 100 |
run_button = gr.Button("Run Vectorizer π₯")
|
| 101 |
|
| 102 |
with gr.Column():
|