Arifin commited on
Commit
2558cde
·
1 Parent(s): 9fc41b1
Files changed (1) hide show
  1. app.py +11 -7
app.py CHANGED
@@ -51,7 +51,8 @@ def get_inspection_recommendation(total_area):
51
  return "Immediate inspection required."
52
 
53
  # Define a Gradio interface to input a URL, run inference, and calculate corrosion areas
54
- def url_infer_and_calculate(url, location, unit="pixels", conversion_factor=1, corrosion_type="", inspection_standards=[], ndt_methods=[], recommendation="", files=[]):
 
55
  try:
56
  # Run inference using the Roboflow script
57
  rf_project = rf.workspace().project("corrosion-instance-segmentation-sfcpc")
@@ -75,11 +76,13 @@ def url_infer_and_calculate(url, location, unit="pixels", conversion_factor=1, c
75
  df.to_csv('Corrosion_Report.csv', index=False)
76
 
77
  # Add the new inputs to the result
78
- result["corrosion_type"] = corrosion_type
79
- result["inspection_standards"] = inspection_standards
80
- result["ndt_methods"] = ndt_methods
81
- result["manual_recommendation"] = recommendation
82
- result["files"] = [f.name for f in files]
 
 
83
 
84
  # Return the path of the CSV file along with other outputs.
85
  return img, corrosion_areas, prediction_json, os.path.abspath('Corrosion_Report.csv'), result
@@ -87,7 +90,8 @@ def url_infer_and_calculate(url, location, unit="pixels", conversion_factor=1, c
87
  except Exception as e:
88
  return {"error": str(e)}
89
 
90
- # Create a Gradio interface for URL input, inference, and corrosion area calculation
 
91
  # Create a Gradio interface for URL input, inference, and corrosion area calculation
92
  iface = gr.Interface(
93
  fn=url_infer_and_calculate,
 
51
  return "Immediate inspection required."
52
 
53
  # Define a Gradio interface to input a URL, run inference, and calculate corrosion areas
54
+ # Define a Gradio interface to input a URL, run inference, and calculate corrosion areas
55
+ def url_infer_and_calculate(url, location=None, unit="pixels", conversion_factor=1, corrosion_type=None, inspection_standards=None, ndt_methods=None, recommendation=None, files=None):
56
  try:
57
  # Run inference using the Roboflow script
58
  rf_project = rf.workspace().project("corrosion-instance-segmentation-sfcpc")
 
76
  df.to_csv('Corrosion_Report.csv', index=False)
77
 
78
  # Add the new inputs to the result
79
+ result = {
80
+ "corrosion_type": corrosion_type,
81
+ "inspection_standards": inspection_standards,
82
+ "ndt_methods": ndt_methods,
83
+ "manual_recommendation": recommendation,
84
+ "files": [f.name for f in files] if files else []
85
+ }
86
 
87
  # Return the path of the CSV file along with other outputs.
88
  return img, corrosion_areas, prediction_json, os.path.abspath('Corrosion_Report.csv'), result
 
90
  except Exception as e:
91
  return {"error": str(e)}
92
 
93
+
94
+
95
  # Create a Gradio interface for URL input, inference, and corrosion area calculation
96
  iface = gr.Interface(
97
  fn=url_infer_and_calculate,