martin8 commited on
Commit
c48244b
1 Parent(s): dad9731

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +46 -47
app.py CHANGED
@@ -686,9 +686,6 @@ def task_categorization_model_predictions():
686
 
687
 
688
  def model_selector_sbert():
689
-
690
- st.image("./panelup.png")
691
-
692
  # st.title("Text Analysis App")
693
 
694
  data = ""
@@ -697,6 +694,7 @@ def model_selector_sbert():
697
 
698
  st.write("""Enter a brief description of your task, and this app will recommend an AI model for you!""")
699
 
 
700
  # st.markdown(f'<p style="color: #012d51;font-size:18px;border-radius:%;">{"Please, describe your AI application below:"}</p>', unsafe_allow_html=True)
701
 
702
  prompt = st.text_area("Describe your task:")
@@ -704,51 +702,52 @@ def model_selector_sbert():
704
  st.write("")
705
  st.write("")
706
 
707
- if prompt != "":
708
- sbert_saved_model = torch.load("Sbert_saved_model", map_location=torch.device('cpu')).to("cpu")
709
- model = sbert_saved_model.to("cpu")
710
- tokenizer = AutoTokenizer.from_pretrained("sentence-transformers/all-mpnet-base-v2")
711
- pipe = TextClassificationPipeline(model= model, tokenizer=tokenizer, return_all_scores=True)
712
- # outputs a list of dicts like [[{'label': 'NEGATIVE', 'score': 0.0001223755971295759}, {'label': 'POSITIVE', 'score': 0.9998776316642761}]]
713
-
714
- # prompt = ["What is the the best ai for putting text report into data table?","How can I generate car sales agreement with ai model?","AI model to detect burglar on 48 hours of cctv video footage","I need Ai model help me with rewriting 50 financial statements emails into one summary report ?","I need a model for extracting person from an image"]
715
- # responses = pipe(prompt)
716
-
717
-
718
- models_list = pd.read_csv("models.csv")
719
- # st.write(get_top_3(prompt))
720
-
721
- top_cat, top_models = get_top_3_a(prompt,pipe)
722
- # prompt = input("Enter your AI task idea:")
723
- # top_cats,cat_to_models = get_models(prompt)
724
-
725
- # top_models = cat_to_models[top_cats[0]]
726
-
727
- top_cat = " " + top_cat[0].upper() + top_cat[1:]
728
- st.markdown(f'<p style="color: #012d51;font-size:24px;border-radius:%;">{"Recognized AI Domain Category: "}</p>', unsafe_allow_html=True)
729
-
730
- st.markdown(f'<p style="background-color:#12d51; color:#1782ea;font-size:18px;border-radius:%;">{top_cat}</p>', unsafe_allow_html=True)
731
- # st.write("Recommended AI Domain Type: ",top_cat)
732
- # st.write("Recommended Models for category: ",top_cats[0], " are:",top_models)
733
-
734
- # st.write("Recommended Task category: ",top_models[0])
735
-
736
-
737
- st.markdown(f'<p style=" margin-left: 0px;color: #012d51;font-size:18px;border-radius:%;">{"The best models selected for this task:"}</p>', unsafe_allow_html=True)
738
-
739
-
740
- st.markdown(f'<p style="margin-left: 0px;background-color:#e1e1e1; color:#012d51;font-size:18px;border-radius:%;">{"1- "+top_models[0]}</p>', unsafe_allow_html=True)
741
-
742
- st.image("./buttons1.png")
743
-
744
- if st.button("Show more"):
745
-
746
- st.markdown(f'<p style="margin-left: 0px;background-color:#e1e1e1; color:#012d51;font-size:18px;border-radius:%;">{"2- "+top_models[1]}</p>', unsafe_allow_html=True)
747
- st.image("./buttons1.png")
748
-
749
-
750
- st.markdown(f'<p style="margin-left: 0px;background-color:#e1e1e1; color:#012d51;font-size:18px;border-radius:%;">{"3- "+top_models[2]}</p>', unsafe_allow_html=True)
751
  st.image("./buttons1.png")
 
 
 
 
 
 
 
 
 
752
 
753
 
754
 
 
686
 
687
 
688
  def model_selector_sbert():
 
 
 
689
  # st.title("Text Analysis App")
690
 
691
  data = ""
 
694
 
695
  st.write("""Enter a brief description of your task, and this app will recommend an AI model for you!""")
696
 
697
+ st.image("./panelup.png")
698
  # st.markdown(f'<p style="color: #012d51;font-size:18px;border-radius:%;">{"Please, describe your AI application below:"}</p>', unsafe_allow_html=True)
699
 
700
  prompt = st.text_area("Describe your task:")
 
702
  st.write("")
703
  st.write("")
704
 
705
+ if st.button("Recommend Model"):
706
+ if prompt != "":
707
+ sbert_saved_model = torch.load("Sbert_saved_model", map_location=torch.device('cpu')).to("cpu")
708
+ model = sbert_saved_model.to("cpu")
709
+ tokenizer = AutoTokenizer.from_pretrained("sentence-transformers/all-mpnet-base-v2")
710
+ pipe = TextClassificationPipeline(model= model, tokenizer=tokenizer, return_all_scores=True)
711
+ # outputs a list of dicts like [[{'label': 'NEGATIVE', 'score': 0.0001223755971295759}, {'label': 'POSITIVE', 'score': 0.9998776316642761}]]
712
+
713
+ # prompt = ["What is the the best ai for putting text report into data table?","How can I generate car sales agreement with ai model?","AI model to detect burglar on 48 hours of cctv video footage","I need Ai model help me with rewriting 50 financial statements emails into one summary report ?","I need a model for extracting person from an image"]
714
+ # responses = pipe(prompt)
715
+
716
+
717
+ models_list = pd.read_csv("models.csv")
718
+ # st.write(get_top_3(prompt))
719
+
720
+ top_cat, top_models = get_top_3_a(prompt,pipe)
721
+ # prompt = input("Enter your AI task idea:")
722
+ # top_cats,cat_to_models = get_models(prompt)
723
+
724
+ # top_models = cat_to_models[top_cats[0]]
725
+
726
+ top_cat = " " + top_cat[0].upper() + top_cat[1:]
727
+ st.markdown(f'<p style="color: #012d51;font-size:24px;border-radius:%;">{"Recognized AI Domain Category: "}</p>', unsafe_allow_html=True)
728
+
729
+ st.markdown(f'<p style="background-color:#12d51; color:#1782ea;font-size:18px;border-radius:%;">{top_cat}</p>', unsafe_allow_html=True)
730
+ # st.write("Recommended AI Domain Type: ",top_cat)
731
+ # st.write("Recommended Models for category: ",top_cats[0], " are:",top_models)
732
+
733
+ # st.write("Recommended Task category: ",top_models[0])
734
+
735
+
736
+ st.markdown(f'<p style=" margin-left: 0px;color: #012d51;font-size:18px;border-radius:%;">{"The best models selected for this task:"}</p>', unsafe_allow_html=True)
737
+
738
+
739
+ st.markdown(f'<p style="margin-left: 0px;background-color:#e1e1e1; color:#012d51;font-size:18px;border-radius:%;">{"1- "+top_models[0]}</p>', unsafe_allow_html=True)
740
+
 
 
 
 
 
 
 
 
741
  st.image("./buttons1.png")
742
+
743
+ if st.button("Show more"):
744
+
745
+ st.markdown(f'<p style="margin-left: 0px;background-color:#e1e1e1; color:#012d51;font-size:18px;border-radius:%;">{"2- "+top_models[1]}</p>', unsafe_allow_html=True)
746
+ st.image("./buttons1.png")
747
+
748
+
749
+ st.markdown(f'<p style="margin-left: 0px;background-color:#e1e1e1; color:#012d51;font-size:18px;border-radius:%;">{"3- "+top_models[2]}</p>', unsafe_allow_html=True)
750
+ st.image("./buttons1.png")
751
 
752
 
753