Pranjal Aggarwal commited on
Commit
c4e69b4
1 Parent(s): a56b13f
Files changed (2) hide show
  1. app.py +6 -2
  2. cache.json +0 -0
app.py CHANGED
@@ -11,8 +11,8 @@ from pdb import set_trace as bp
11
 
12
  model = DemoModel()
13
  examples = json.load(open('amzn_examples.json'))
14
- cache = {x['text']: {'label': x['label']} for x in examples}
15
-
16
  unseen_labels = {x.strip() for x in open('cleaned_code/datasets/Amzn13K/unseen_labels_split6500_2.txt')}
17
  all_labels = {x.strip() for x in open('cleaned_code/datasets/Amzn13K/all_labels.txt')}
18
 
@@ -55,6 +55,7 @@ def classify(text, is_unseen):
55
  cache[text] = dict()
56
  cache[text]['preds'] = preds
57
  cache[text]['descs'] = descs
 
58
 
59
  print(text, preds)
60
  # return preds
@@ -84,6 +85,9 @@ def toggle_descriptions_fn():
84
  descriptions_visible = not descriptions_visible
85
  return descriptions_visible
86
 
 
 
 
87
 
88
  with gr.Blocks(css="#warning {height: 100%}") as demo:
89
  with gr.Column():
 
11
 
12
  model = DemoModel()
13
  examples = json.load(open('amzn_examples.json'))
14
+ # cache = {x['text']: {'label': x['label']} for x in examples}
15
+ cache = json.load(open('cache.json'))
16
  unseen_labels = {x.strip() for x in open('cleaned_code/datasets/Amzn13K/unseen_labels_split6500_2.txt')}
17
  all_labels = {x.strip() for x in open('cleaned_code/datasets/Amzn13K/all_labels.txt')}
18
 
 
55
  cache[text] = dict()
56
  cache[text]['preds'] = preds
57
  cache[text]['descs'] = descs
58
+ json.dump(cache, open('cache.json','w'), indent = 2)
59
 
60
  print(text, preds)
61
  # return preds
 
85
  descriptions_visible = not descriptions_visible
86
  return descriptions_visible
87
 
88
+ # for example in examples:
89
+ # classify(example['text'], False)
90
+
91
 
92
  with gr.Blocks(css="#warning {height: 100%}") as demo:
93
  with gr.Column():
cache.json ADDED
The diff for this file is too large to render. See raw diff