pragnakalp commited on
Commit
cb88ed2
1 Parent(s): e0a4914

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +8 -8
app.py CHANGED
@@ -30,16 +30,16 @@ 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.mkdir("ocr_data")
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:
@@ -136,11 +136,11 @@ def generate_ocr(Method,img):
136
  imge = Image.fromarray(new_data.astype(np.uint8),'RGB')
137
  add_csv = [Method,imge,text_output]
138
 
139
- # with open(DATA_FILE, "a") as f:
140
- # writer = csv.writer(f)
141
- # write the data
142
- # writer.writerow(add_csv)
143
- os.mkdir(DATA_FILE2)
144
  commit_url = repo.push_to_hub()
145
  print(commit_url)
146
  try:
 
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.mkdir("ocr_data")
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_FILENAME,
41
  cache_dir=DATA_DIRNAME,
42
+ force_filename=DATA_FILENAME
43
  )
44
 
45
  except:
 
136
  imge = Image.fromarray(new_data.astype(np.uint8),'RGB')
137
  add_csv = [Method,imge,text_output]
138
 
139
+ with open(DATA_FILE, "a") as f:
140
+ writer = csv.writer(f)
141
+ write the data
142
+ writer.writerow(add_csv)
143
+ # os.mkdir(DATA_FILE2)
144
  commit_url = repo.push_to_hub()
145
  print(commit_url)
146
  try: