Sanjayraju30 commited on
Commit
d856f9f
·
verified ·
1 Parent(s): 76bdd59

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -5
app.py CHANGED
@@ -1,5 +1,4 @@
1
  import gradio as gr
2
- from PIL import Image
3
  from ocr_engine import extract_weight_from_image
4
  from utils import get_ist_time
5
 
@@ -7,15 +6,15 @@ def process_image(image):
7
  try:
8
  if image is None:
9
  return "No image provided", "-", None, "-"
10
-
11
  weight, confidence = extract_weight_from_image(image)
12
  timestamp = get_ist_time()
13
 
14
  if not weight:
15
  return "No weight detected", timestamp, image, "-"
16
 
17
- log_url = f"https://your-salesforce-site.com/log-weight?weight={weight}&time={timestamp}"
18
- return f"{weight} g (Confidence: {confidence}%)", timestamp, image, log_url
19
 
20
  except Exception as e:
21
  return f"Error: {str(e)}", "-", None, "-"
@@ -30,7 +29,7 @@ iface = gr.Interface(
30
  gr.Textbox(label="Salesforce Log URL"),
31
  ],
32
  title="⚖️ Auto Weight Logger",
33
- description="Upload or capture an image to extract the weight and log the result.",
34
  live=True,
35
  )
36
 
 
1
  import gradio as gr
 
2
  from ocr_engine import extract_weight_from_image
3
  from utils import get_ist_time
4
 
 
6
  try:
7
  if image is None:
8
  return "No image provided", "-", None, "-"
9
+
10
  weight, confidence = extract_weight_from_image(image)
11
  timestamp = get_ist_time()
12
 
13
  if not weight:
14
  return "No weight detected", timestamp, image, "-"
15
 
16
+ sf_url = f"https://your-salesforce-site.com/log-weight?weight={weight}&time={timestamp}"
17
+ return f"{weight} g (Confidence: {confidence}%)", timestamp, image, sf_url
18
 
19
  except Exception as e:
20
  return f"Error: {str(e)}", "-", None, "-"
 
29
  gr.Textbox(label="Salesforce Log URL"),
30
  ],
31
  title="⚖️ Auto Weight Logger",
32
+ description="Upload or capture a digital scale image to extract the weight.",
33
  live=True,
34
  )
35