Spaces:
Running
Running
pragnakalp
commited on
Commit
•
7cd3a92
1
Parent(s):
afa9234
Update app.py
Browse files
app.py
CHANGED
@@ -29,15 +29,17 @@ HF_TOKEN = os.environ.get("HF_TOKEN")
|
|
29 |
DATASET_REPO_URL = "https://huggingface.co/datasets/pragnakalp/OCR-img-to-text"
|
30 |
DATA_FILENAME = "ocr_data.csv"
|
31 |
DATA_FILE = os.path.join("ocr_data", DATA_FILENAME)
|
|
|
|
|
32 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
33 |
DATASET_REPO_ID = "pragnakalp/OCR-img-to-text"
|
34 |
print("is none?", HF_TOKEN is None)
|
35 |
try:
|
36 |
hf_hub_download(
|
37 |
repo_id=DATASET_REPO_ID,
|
38 |
-
filename=
|
39 |
cache_dir=DATA_DIRNAME,
|
40 |
-
force_filename=
|
41 |
)
|
42 |
|
43 |
except:
|
@@ -135,22 +137,26 @@ def generate_ocr(Method,img):
|
|
135 |
imge = Image.fromarray(new_data.astype(np.uint8),'RGB')
|
136 |
add_csv = [Method,imge,text_output]
|
137 |
print("^^^^^",type(imge))
|
138 |
-
with open(DATA_FILE, "a") as f:
|
139 |
-
writer = csv.writer(f)
|
140 |
# write the data
|
141 |
-
writer.writerow(add_csv)
|
142 |
-
|
143 |
-
|
|
|
144 |
try:
|
145 |
dataset = load_dataset("pragnakalp/OCR-img-to-text", data_files= "ocr_data.csv", streaming=True)
|
146 |
print(dataset)
|
147 |
except Exception as e:
|
148 |
print("error in loading data",e)
|
|
|
|
|
149 |
# with open(DATA_FILE, "a") as csvfile:
|
150 |
# writer = csv.Writer(csvfile)
|
151 |
# writer.writerow(add_csv)
|
152 |
# commit_url = repo.push_to_hub()
|
153 |
# print(commit_url)
|
|
|
154 |
# save_details(Method,text_output,img)
|
155 |
# sender="[email protected]"
|
156 |
# password="httscgatatbbxxur"
|
|
|
29 |
DATASET_REPO_URL = "https://huggingface.co/datasets/pragnakalp/OCR-img-to-text"
|
30 |
DATA_FILENAME = "ocr_data.csv"
|
31 |
DATA_FILE = os.path.join("ocr_data", DATA_FILENAME)
|
32 |
+
DATA_FILENAME2 = "ocr_image"
|
33 |
+
DATA_FILE2 = os.path.join("ocr_image", DATA_FILENAME2)
|
34 |
HF_TOKEN = os.environ.get("HF_TOKEN")
|
35 |
DATASET_REPO_ID = "pragnakalp/OCR-img-to-text"
|
36 |
print("is none?", HF_TOKEN is None)
|
37 |
try:
|
38 |
hf_hub_download(
|
39 |
repo_id=DATASET_REPO_ID,
|
40 |
+
filename=DATA_FILENAME2,
|
41 |
cache_dir=DATA_DIRNAME,
|
42 |
+
force_filename=DATA_FILENAME2
|
43 |
)
|
44 |
|
45 |
except:
|
|
|
137 |
imge = Image.fromarray(new_data.astype(np.uint8),'RGB')
|
138 |
add_csv = [Method,imge,text_output]
|
139 |
print("^^^^^",type(imge))
|
140 |
+
# with open(DATA_FILE, "a") as f:
|
141 |
+
# writer = csv.writer(f)
|
142 |
# write the data
|
143 |
+
# writer.writerow(add_csv)
|
144 |
+
os.mkdir(DATA_FILE2)
|
145 |
+
commit_url = repo.push_to_hub()
|
146 |
+
print(commit_url)
|
147 |
try:
|
148 |
dataset = load_dataset("pragnakalp/OCR-img-to-text", data_files= "ocr_data.csv", streaming=True)
|
149 |
print(dataset)
|
150 |
except Exception as e:
|
151 |
print("error in loading data",e)
|
152 |
+
|
153 |
+
|
154 |
# with open(DATA_FILE, "a") as csvfile:
|
155 |
# writer = csv.Writer(csvfile)
|
156 |
# writer.writerow(add_csv)
|
157 |
# commit_url = repo.push_to_hub()
|
158 |
# print(commit_url)
|
159 |
+
|
160 |
# save_details(Method,text_output,img)
|
161 |
# sender="[email protected]"
|
162 |
# password="httscgatatbbxxur"
|