SatyamSinghal commited on
Commit
2cf552b
·
verified ·
1 Parent(s): 851f137

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -0
app.py CHANGED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import cv2
3
+ import numpy as np
4
+ import pandas as pd
5
+ from utils import detect_spots, calculate_rf, annotate_image
6
+
7
+ def process_tlc(image, solvent_front_y, baseline_y):
8
+ # Detect spots
9
+ spots = detect_spots(image)
10
+
11
+ # Calculate Rf values
12
+ rf_values = calculate_rf(spots, solvent_front_y, baseline_y)
13
+
14
+ # Annotate image
15
+ annotated_image = annotate_image(image, spots, rf_values)
16
+
17
+ # Generate a CSV report
18
+ report_data = {"Spot": list(range(1, len(spots) + 1)), "Rf Value": rf_values}
19
+ report = pd.DataFrame(report_data).to_csv(index=False)
20
+
21
+ return annotated_image, report
22
+
23
+ # Gradio Interface
24
+ interface = gr.Interface(
25
+ fn=process_tlc,
26
+ inputs=[
27
+ gr.Image(type="numpy", label="Upload TLC Plate Image"),
28
+ gr.Number(label="Solvent Front Y-Coordinate"),
29
+ gr.Number(label="Baseline Y-Coordinate"),
30
+ ],
31
+ outputs=[
32
+ gr.Image(label="Annotated TLC Plate"),
33
+ gr.File(label="Download Rf Report (CSV)"),
34
+ ],
35
+ title="TLC Analyzer",
36
+ description="Upload a TLC plate image and provide the Y-coordinates for the solvent front and baseline. The tool will calculate Rf values and annotate the image."
37
+ )
38
+
39
+ if __name__ == "__main__":
40
+ interface.launch()