Seetha commited on
Commit
b5c002a
1 Parent(s): e2d98db

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +25 -14
app.py CHANGED
@@ -62,25 +62,22 @@ from datetime import datetime
62
  import pathlib as Path
63
  from requests import get
64
  import urllib.request
 
 
65
 
66
 
67
- # DATASET_REPO_URL = "https://huggingface.co/datasets/Seetha/visual_files/raw/main/level2.json"
68
- # DATA_FILENAME = "level2.json"
69
- # #DATA_FILE = os.path.join(DATASET_REPO_URL, DATA_FILENAME)
70
 
71
- # # feedback_file = Path("https://huggingface.co/datasets/Seetha/visual_files/") / f"level2.json"
72
- # st.write(DATASET_REPO_URL)
73
 
74
- # HF_TOKEN = os.environ.get("HF_TOKEN")
75
 
76
- # repo = Repository(
77
- # local_dir="huggingface-hub", clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
78
- # )
79
- #dataset = load_dataset('Seetha/visual_files')
80
-
81
- # print("is none?", HF_TOKEN is None)
82
-
83
- # print("hfh", huggingface_hub.__version__)
84
 
85
 
86
  def main():
@@ -501,6 +498,20 @@ def main():
501
  # f.seek(0)
502
  st.write(str(json_data))
503
  json.dump(json_data, f)
 
 
 
 
 
 
 
 
 
 
 
 
 
 
504
  #f.truncate()
505
 
506
  df_final1.to_csv('predictions.csv')
 
62
  import pathlib as Path
63
  from requests import get
64
  import urllib.request
65
+ import gradio as gr
66
+ from gradio import inputs, outputs
67
 
68
 
69
+ DATASET_REPO_URL = "https://huggingface.co/datasets/Seetha/visual_files"
70
+ DATA_FILENAME = "level2.json"
71
+ DATA_FILE = os.path.join("level2", DATA_FILENAME)
72
 
73
+ HF_TOKEN = os.environ.get("HF_TOKEN")
74
+ st.write("is none?", HF_TOKEN is None)
75
 
76
+ st.write("hfh", huggingface_hub.__version__)
77
 
78
+ repo = Repository(
79
+ local_dir="level2", clone_from=DATASET_REPO_URL, use_auth_token=HF_TOKEN
80
+ )
 
 
 
 
 
81
 
82
 
83
  def main():
 
498
  # f.seek(0)
499
  st.write(str(json_data))
500
  json.dump(json_data, f)
501
+
502
+ def store_message():
503
+ with open(DATA_FILE, "w") as f:
504
+ json.dump(json_data, f)
505
+ commit_url = repo.push_to_hub()
506
+ st.write(commit_url)
507
+
508
+ #return generate_html()
509
+ iface = gr.Interface(
510
+ store_message()
511
+ )
512
+
513
+ iface.launch()
514
+
515
  #f.truncate()
516
 
517
  df_final1.to_csv('predictions.csv')