map222 commited on
Commit
93c4058
1 Parent(s): 77ec2cc

Trying to fix bugs

Browse files

Simplify to most similar

Files changed (1) hide show
  1. app.py +7 -7
app.py CHANGED
@@ -2,16 +2,14 @@ import gradio as gr
2
  import pandas as pd
3
 
4
  from huggingface_hub import hf_hub_url, cached_download
5
- from gensim.models.fasttext import KeyedVector
6
-
7
- ACCESS_KEY = os.environ.get('ACCESS_KEY')
8
-
9
 
10
  # Setup model
11
  url = hf_hub_url(repo_id="map222/recipe-spice-model", filename="recipe_w2v.gensim")
12
  cached_download(url)
13
  recipe_w2v = KeyedVectors.load(cached_download(url) )
14
 
 
15
  url = hf_hub_url(repo_id="map222/recipe-spice-model", filename="ingredient_count.json")
16
  cached_download(url)
17
  ingredient_count = json.load(cached_download(url) )
@@ -20,6 +18,8 @@ url = hf_hub_url(repo_id="map222/recipe-spice-model", filename="recipe_NER.tsv")
20
  cached_download(url)
21
  recipe_NER = pd.read_csv(cached_download(url), sep='\t' )
22
 
 
 
23
  app = gr.Blocks()
24
 
25
  def get_fusion_ingredients(ingredient: str,
@@ -44,8 +44,9 @@ def get_fusion_ingredients(ingredient: str,
44
  return top_candidates, cooccurrence_counts, ingredient_candidates # return multiple for debugging
45
 
46
  def helper_func(text):
47
- a,b,c = get_fusion_ingredients(x, recipe_w2v, ingredient_count, recipe_NER)
48
- return pd.DataFrame(a)
 
49
 
50
  with app:
51
  gr.Markdown("# Recipe Spice")
@@ -55,7 +56,6 @@ with app:
55
 
56
 
57
  with gr.Row():
58
-
59
  df_out = gr.Dataframe(interactive=False)
60
  with gr.Row():
61
  gr.Markdown(
 
2
  import pandas as pd
3
 
4
  from huggingface_hub import hf_hub_url, cached_download
5
+ from gensim.models import KeyedVectors
 
 
 
6
 
7
  # Setup model
8
  url = hf_hub_url(repo_id="map222/recipe-spice-model", filename="recipe_w2v.gensim")
9
  cached_download(url)
10
  recipe_w2v = KeyedVectors.load(cached_download(url) )
11
 
12
+ '''
13
  url = hf_hub_url(repo_id="map222/recipe-spice-model", filename="ingredient_count.json")
14
  cached_download(url)
15
  ingredient_count = json.load(cached_download(url) )
 
18
  cached_download(url)
19
  recipe_NER = pd.read_csv(cached_download(url), sep='\t' )
20
 
21
+ '''
22
+
23
  app = gr.Blocks()
24
 
25
  def get_fusion_ingredients(ingredient: str,
 
44
  return top_candidates, cooccurrence_counts, ingredient_candidates # return multiple for debugging
45
 
46
  def helper_func(text):
47
+ #a,b,c = get_fusion_ingredients(x, recipe_w2v, ingredient_count, recipe_NER)
48
+ nearest = recipe_w2v.most_similar(text)
49
+ return pd.DataFrame(nearest)
50
 
51
  with app:
52
  gr.Markdown("# Recipe Spice")
 
56
 
57
 
58
  with gr.Row():
 
59
  df_out = gr.Dataframe(interactive=False)
60
  with gr.Row():
61
  gr.Markdown(