Dharini Baskaran commited on
Commit
63642bb
Β·
1 Parent(s): 10bbab5

updating docker

Browse files
Files changed (1) hide show
  1. app.py +14 -10
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="file")
 
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():