Spaces:
Sleeping
Sleeping
Upload folder using huggingface_hub
Browse files- app.py +4 -10
- requirements.txt +6 -8
- sample_data/README.md +19 -0
- sample_data/anscombe.json +49 -0
- sample_data/california_housing_test.csv +0 -0
- sample_data/california_housing_train.csv +0 -0
- sample_data/mnist_test.csv +3 -0
- sample_data/mnist_train_small.csv +3 -0
app.py
CHANGED
|
@@ -1,3 +1,4 @@
|
|
|
|
|
| 1 |
import os
|
| 2 |
import subprocess
|
| 3 |
import sys
|
|
@@ -134,23 +135,16 @@ def dummy_analyze(ingredients_list, health_conditions=None):
|
|
| 134 |
return report
|
| 135 |
|
| 136 |
# Function to extract text from images using OCR
|
| 137 |
-
# Replace your current extract_text_from_image function with this:
|
| 138 |
-
|
| 139 |
def extract_text_from_image(image):
|
| 140 |
try:
|
| 141 |
if image is None:
|
| 142 |
return "No image captured. Please try again."
|
| 143 |
|
| 144 |
-
# Print tesseract path for debugging
|
| 145 |
-
print(f"Using tesseract path: {pytesseract.pytesseract.tesseract_cmd}")
|
| 146 |
-
|
| 147 |
# Verify Tesseract executable is accessible
|
| 148 |
try:
|
| 149 |
-
|
| 150 |
check=True, capture_output=True, text=True)
|
| 151 |
-
|
| 152 |
-
except Exception as e:
|
| 153 |
-
print(f"Tesseract verification failed: {str(e)}")
|
| 154 |
return "Tesseract OCR is not installed or not properly configured. Please check installation."
|
| 155 |
|
| 156 |
# Import necessary libraries
|
|
@@ -433,4 +427,4 @@ with gr.Blocks(title="AI Ingredient Scanner") as app:
|
|
| 433 |
|
| 434 |
# Launch the app
|
| 435 |
if __name__ == "__main__":
|
| 436 |
-
app.launch()
|
|
|
|
| 1 |
+
|
| 2 |
import os
|
| 3 |
import subprocess
|
| 4 |
import sys
|
|
|
|
| 135 |
return report
|
| 136 |
|
| 137 |
# Function to extract text from images using OCR
|
|
|
|
|
|
|
| 138 |
def extract_text_from_image(image):
|
| 139 |
try:
|
| 140 |
if image is None:
|
| 141 |
return "No image captured. Please try again."
|
| 142 |
|
|
|
|
|
|
|
|
|
|
| 143 |
# Verify Tesseract executable is accessible
|
| 144 |
try:
|
| 145 |
+
subprocess.run([pytesseract.pytesseract.tesseract_cmd, "--version"],
|
| 146 |
check=True, capture_output=True, text=True)
|
| 147 |
+
except (subprocess.SubprocessError, FileNotFoundError):
|
|
|
|
|
|
|
| 148 |
return "Tesseract OCR is not installed or not properly configured. Please check installation."
|
| 149 |
|
| 150 |
# Import necessary libraries
|
|
|
|
| 427 |
|
| 428 |
# Launch the app
|
| 429 |
if __name__ == "__main__":
|
| 430 |
+
app.launch()
|
requirements.txt
CHANGED
|
@@ -1,4 +1,9 @@
|
|
| 1 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 2 |
fastapi
|
| 3 |
uvicorn
|
| 4 |
gradio
|
|
@@ -7,10 +12,3 @@ Pillow
|
|
| 7 |
opencv-python-headless
|
| 8 |
python-dotenv
|
| 9 |
dotenv
|
| 10 |
-
torch>=2.0.0
|
| 11 |
-
transformers>=4.30.0
|
| 12 |
-
numpy>=1.24.0
|
| 13 |
-
pytesseract>=0.3.8
|
| 14 |
-
opencv-python-headless>=4.5.0
|
| 15 |
-
requests>=2.25.0
|
| 16 |
-
|
|
|
|
| 1 |
+
gradio>=3.50.2
|
| 2 |
+
torch>=2.0.0
|
| 3 |
+
transformers>=4.30.0
|
| 4 |
+
Pillow>=9.0.0
|
| 5 |
+
numpy>=1.24.0
|
| 6 |
+
|
| 7 |
fastapi
|
| 8 |
uvicorn
|
| 9 |
gradio
|
|
|
|
| 12 |
opencv-python-headless
|
| 13 |
python-dotenv
|
| 14 |
dotenv
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
sample_data/README.md
ADDED
|
@@ -0,0 +1,19 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
This directory includes a few sample datasets to get you started.
|
| 2 |
+
|
| 3 |
+
* `california_housing_data*.csv` is California housing data from the 1990 US
|
| 4 |
+
Census; more information is available at:
|
| 5 |
+
https://docs.google.com/document/d/e/2PACX-1vRhYtsvc5eOR2FWNCwaBiKL6suIOrxJig8LcSBbmCbyYsayia_DvPOOBlXZ4CAlQ5nlDD8kTaIDRwrN/pub
|
| 6 |
+
|
| 7 |
+
* `mnist_*.csv` is a small sample of the
|
| 8 |
+
[MNIST database](https://en.wikipedia.org/wiki/MNIST_database), which is
|
| 9 |
+
described at: http://yann.lecun.com/exdb/mnist/
|
| 10 |
+
|
| 11 |
+
* `anscombe.json` contains a copy of
|
| 12 |
+
[Anscombe's quartet](https://en.wikipedia.org/wiki/Anscombe%27s_quartet); it
|
| 13 |
+
was originally described in
|
| 14 |
+
|
| 15 |
+
Anscombe, F. J. (1973). 'Graphs in Statistical Analysis'. American
|
| 16 |
+
Statistician. 27 (1): 17-21. JSTOR 2682899.
|
| 17 |
+
|
| 18 |
+
and our copy was prepared by the
|
| 19 |
+
[vega_datasets library](https://github.com/altair-viz/vega_datasets/blob/4f67bdaad10f45e3549984e17e1b3088c731503d/vega_datasets/_data/anscombe.json).
|
sample_data/anscombe.json
ADDED
|
@@ -0,0 +1,49 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
[
|
| 2 |
+
{"Series":"I", "X":10.0, "Y":8.04},
|
| 3 |
+
{"Series":"I", "X":8.0, "Y":6.95},
|
| 4 |
+
{"Series":"I", "X":13.0, "Y":7.58},
|
| 5 |
+
{"Series":"I", "X":9.0, "Y":8.81},
|
| 6 |
+
{"Series":"I", "X":11.0, "Y":8.33},
|
| 7 |
+
{"Series":"I", "X":14.0, "Y":9.96},
|
| 8 |
+
{"Series":"I", "X":6.0, "Y":7.24},
|
| 9 |
+
{"Series":"I", "X":4.0, "Y":4.26},
|
| 10 |
+
{"Series":"I", "X":12.0, "Y":10.84},
|
| 11 |
+
{"Series":"I", "X":7.0, "Y":4.81},
|
| 12 |
+
{"Series":"I", "X":5.0, "Y":5.68},
|
| 13 |
+
|
| 14 |
+
{"Series":"II", "X":10.0, "Y":9.14},
|
| 15 |
+
{"Series":"II", "X":8.0, "Y":8.14},
|
| 16 |
+
{"Series":"II", "X":13.0, "Y":8.74},
|
| 17 |
+
{"Series":"II", "X":9.0, "Y":8.77},
|
| 18 |
+
{"Series":"II", "X":11.0, "Y":9.26},
|
| 19 |
+
{"Series":"II", "X":14.0, "Y":8.10},
|
| 20 |
+
{"Series":"II", "X":6.0, "Y":6.13},
|
| 21 |
+
{"Series":"II", "X":4.0, "Y":3.10},
|
| 22 |
+
{"Series":"II", "X":12.0, "Y":9.13},
|
| 23 |
+
{"Series":"II", "X":7.0, "Y":7.26},
|
| 24 |
+
{"Series":"II", "X":5.0, "Y":4.74},
|
| 25 |
+
|
| 26 |
+
{"Series":"III", "X":10.0, "Y":7.46},
|
| 27 |
+
{"Series":"III", "X":8.0, "Y":6.77},
|
| 28 |
+
{"Series":"III", "X":13.0, "Y":12.74},
|
| 29 |
+
{"Series":"III", "X":9.0, "Y":7.11},
|
| 30 |
+
{"Series":"III", "X":11.0, "Y":7.81},
|
| 31 |
+
{"Series":"III", "X":14.0, "Y":8.84},
|
| 32 |
+
{"Series":"III", "X":6.0, "Y":6.08},
|
| 33 |
+
{"Series":"III", "X":4.0, "Y":5.39},
|
| 34 |
+
{"Series":"III", "X":12.0, "Y":8.15},
|
| 35 |
+
{"Series":"III", "X":7.0, "Y":6.42},
|
| 36 |
+
{"Series":"III", "X":5.0, "Y":5.73},
|
| 37 |
+
|
| 38 |
+
{"Series":"IV", "X":8.0, "Y":6.58},
|
| 39 |
+
{"Series":"IV", "X":8.0, "Y":5.76},
|
| 40 |
+
{"Series":"IV", "X":8.0, "Y":7.71},
|
| 41 |
+
{"Series":"IV", "X":8.0, "Y":8.84},
|
| 42 |
+
{"Series":"IV", "X":8.0, "Y":8.47},
|
| 43 |
+
{"Series":"IV", "X":8.0, "Y":7.04},
|
| 44 |
+
{"Series":"IV", "X":8.0, "Y":5.25},
|
| 45 |
+
{"Series":"IV", "X":19.0, "Y":12.50},
|
| 46 |
+
{"Series":"IV", "X":8.0, "Y":5.56},
|
| 47 |
+
{"Series":"IV", "X":8.0, "Y":7.91},
|
| 48 |
+
{"Series":"IV", "X":8.0, "Y":6.89}
|
| 49 |
+
]
|
sample_data/california_housing_test.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
sample_data/california_housing_train.csv
ADDED
|
The diff for this file is too large to render.
See raw diff
|
|
|
sample_data/mnist_test.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:51c292478d94ec3a01461bdfa82eb0885d262eb09e615679b2d69dedb6ad09e7
|
| 3 |
+
size 18289443
|
sample_data/mnist_train_small.csv
ADDED
|
@@ -0,0 +1,3 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
version https://git-lfs.github.com/spec/v1
|
| 2 |
+
oid sha256:1ef64781aa03180f4f5ce504314f058f5d0227277df86060473d973cf43b033e
|
| 3 |
+
size 36523880
|