Arifin commited on
Commit
f2209a5
·
1 Parent(s): 16a65fc
Files changed (1) hide show
  1. app.py +6 -6
app.py CHANGED
@@ -7,7 +7,7 @@ import requests
7
  from io import BytesIO
8
  import pandas as pd
9
  import os
10
-
11
  # Initialize Roboflow with your API key
12
  rf = Roboflow(api_key="kKDoCn3ABT9AKeFQDCB4")
13
 
@@ -73,10 +73,10 @@ def url_infer_and_calculate(url, location, unit="pixels", conversion_factor=1, c
73
  # Create a pandas DataFrame for reporting
74
  df = pd.DataFrame([{'Number': index+1, 'URL': url, 'Location': location, 'corrosion_areas': corrosion_areas, 'Recommendation': corrosion_areas['recommendation']} for index in range(len(corrosion_areas))])
75
 
76
- # Write DataFrame to a string in CSV format
77
- csv_string = df.to_csv(index=False)
78
 
79
- return img, corrosion_areas, prediction_json, csv_string
80
 
81
  except Exception as e:
82
  return {"error": str(e)}
@@ -87,7 +87,7 @@ iface = gr.Interface(
87
  inputs=[
88
  gr.inputs.Textbox(label="Enter the URL of an image"),
89
  gr.inputs.Textbox(label="Enter the Location"),
90
- gr.inputs.Dropdown(choices=["pixels", "cm??"], label="Area Unit"),
91
  gr.inputs.Textbox(label="Conversion Factor"),
92
  gr.inputs.Textbox(label="Enter the Corrosion Type"),
93
  gr.inputs.CheckboxGroup(choices=[f"Standard {i+1}" for i in range(10)], label="Inspection Standards"),
@@ -95,7 +95,7 @@ iface = gr.Interface(
95
  gr.inputs.Textbox(label="Enter Manual Recommendation"),
96
  gr.inputs.Textbox(lines=5, label="Enter Supporting Data URLs (separated by commas)")
97
  ],
98
- outputs=[gr.outputs.Image(type="pil"), "json", "json", gr.outputs.Textbox(label="CSV Data")],
99
  title="Tim CCG",
100
  description="Enter the URL of an image to perform rust detection and calculate corrosion areas.",
101
  )
 
7
  from io import BytesIO
8
  import pandas as pd
9
  import os
10
+ import io
11
  # Initialize Roboflow with your API key
12
  rf = Roboflow(api_key="kKDoCn3ABT9AKeFQDCB4")
13
 
 
73
  # Create a pandas DataFrame for reporting
74
  df = pd.DataFrame([{'Number': index+1, 'URL': url, 'Location': location, 'corrosion_areas': corrosion_areas, 'Recommendation': corrosion_areas['recommendation']} for index in range(len(corrosion_areas))])
75
 
76
+ # Write DataFrame to local CSV file with index included immediately after creating it.
77
+ df.to_csv('Corrosion_Report.csv', index=False)
78
 
79
+ return img, corrosion_areas, prediction_json
80
 
81
  except Exception as e:
82
  return {"error": str(e)}
 
87
  inputs=[
88
  gr.inputs.Textbox(label="Enter the URL of an image"),
89
  gr.inputs.Textbox(label="Enter the Location"),
90
+ gr.inputs.Dropdown(choices=["pixels", "cm"], label="Area Unit"),
91
  gr.inputs.Textbox(label="Conversion Factor"),
92
  gr.inputs.Textbox(label="Enter the Corrosion Type"),
93
  gr.inputs.CheckboxGroup(choices=[f"Standard {i+1}" for i in range(10)], label="Inspection Standards"),
 
95
  gr.inputs.Textbox(label="Enter Manual Recommendation"),
96
  gr.inputs.Textbox(lines=5, label="Enter Supporting Data URLs (separated by commas)")
97
  ],
98
+ outputs=[gr.outputs.Image(type="pil"), "json", "json"],
99
  title="Tim CCG",
100
  description="Enter the URL of an image to perform rust detection and calculate corrosion areas.",
101
  )