Filimize commited on
Commit
41e916b
1 Parent(s): fe861f5

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +13 -84
app.py CHANGED
@@ -1,88 +1,17 @@
1
- import joblib
2
- import pandas as pd
3
  import streamlit as st
 
4
 
5
- model = joblib.load('model_tree.joblib')
6
- unique_values = joblib.load('unique_values.joblib')
7
-
8
- unique_cap_shape = unique_values["cap-shape"]
9
- unique_cap_surface = unique_values["cap-surface"]
10
- unique_cap_color = unique_values["cap-color"]
11
- unique_bruises = unique_values["bruises"]
12
- unique_odor = unique_values["odor"]
13
- unique_gill_attachment = unique_values["gill-attachment"]
14
- unique_gill_spacing = unique_values["gill-spacing"]
15
- unique_gill_size = unique_values["gill-size"]
16
- unique_gill_color = unique_values['gill-color']
17
- unique_stalk_shape = unique_values["stalk-shape"]
18
- unique_stalk_root = unique_values["stalk-root"]
19
- unique_stalk_surface_above_ring = unique_values["stalk-surface-above-ring"]
20
- unique_stalk_surface_below_ring = unique_values["stalk-surface-below-ring"]
21
- unique_stalk_color_above_ring = unique_values["stalk-color-above-ring"]
22
- unique_stalk_color_below_ring = unique_values["stalk-color-below-ring"]
23
- unique_veil_type = unique_values["veil-type"]
24
- unique_veil_color = unique_values['veil-color']
25
- unique_ring_number = unique_values["ring-number"]
26
- unique_ring_type = unique_values["ring-type"]
27
- unique_spore_print_color = unique_values["spore-print-color"]
28
- unique_population = unique_values["population"]
29
- unique_habitat = unique_values["habitat"]
30
-
31
  def main():
32
- st.title("Is this mushroom eatable")
33
- with st.form("questionaire"):
34
- cap_shape = st.selectbox("cap_shape",options = unique_cap_shape)
35
- cap_surface = st.selectbox("cap_surface",options = unique_cap_surface)
36
- cap_color = st.selectbox("cap_color",options = unique_cap_color)
37
- bruises = st.selectbox("bruises",options = unique_bruises)
38
- odor = st.selectbox("odor",options = unique_odor)
39
- gill_attachment = st.selectbox("gill_attachment",options = unique_gill_attachment)
40
- gill_spacing = st.selectbox("gill_spacing",options = unique_gill_spacing)
41
- gill_size = st.selectbox("gill_size",options = unique_gill_size)
42
- gill_color = st.selectbox("gill_color",options = unique_gill_color)
43
- stalk_shape = st.selectbox("stalk_shape",options = unique_stalk_shape)
44
- stalk_root = st.selectbox("stalk_root",options = unique_stalk_root)
45
- stalk_surface_above_ring = st.selectbox("stalk_surface_above_ring",options = unique_stalk_surface_above_ring)
46
- stalk_surface_below_ring = st.selectbox("stalk_surface_below_ring",options = unique_stalk_surface_below_ring)
47
- stalk_color_above_ring = st.selectbox("stalk_color_above_ring",options = unique_stalk_color_above_ring)
48
- stalk_color_below_ring = st.selectbox("stalk_color_below_ring",options = unique_stalk_color_below_ring)
49
- veil_type = st.selectbox("veil_type",options = unique_veil_type)
50
- veil_color = st.selectbox("veil_color",options = unique_veil_color)
51
- ring_number = st.selectbox("ring_number",options = unique_ring_number)
52
- ring_type = st.selectbox("ring_type",options = unique_ring_type)
53
- spore_print_color = st.selectbox("spore_print_color",options = unique_unique_spore_print_color)
54
- population = st.selectbox("population",options = unique_population)
55
- habitat = st.selectbox("habitat",options = unique_habitat)
56
-
57
-
58
-
59
- clicked = st.form_submit_button("Predict income")
60
  if clicked:
61
- result=model.predict(pd.DataFrame({'cap-shape':[cap_shape],
62
- 'cap-surface':[cap_surface],
63
- 'cap-color':[cap_color],
64
- 'bruises':[bruises],
65
- 'odor':[odor],
66
- 'gill-attachment':[gill_attachment],
67
- 'gill-spacing':[gill_spacing],
68
- 'gill-size':[gill_size],
69
- 'gill-color':[gill_color],
70
- 'stalk-shape':[stalk_shape],
71
- 'stalk-root':[stalk_root],
72
- 'stalk-surface-above-ring':[stalk_surface_above_ring],
73
- 'stalk-surface-below-ring':[stalk_surface_below_ring],
74
- 'stalk-color-above-ring':[stalk_color_above_ring],
75
- 'stalk-color-below-ring':[stalk_color_below_ring],
76
- 'veil-type':[veil_type],
77
- 'veil-color':[veil_color],
78
- 'ring-number':[ring_number],
79
- 'ring-type':[ring_type],
80
- 'spore-print-color':[spore_print_color],
81
- 'population':[population],
82
- 'habitat':[habitat]}))
83
- # Show prediction
84
- result = 'eatable' if result[0]==1 else 'poisonous'
85
- st.success("This Mushroom is "+result)
86
- # Run main()
87
- if __name__=="__main__":
88
- main()
 
 
 
1
  import streamlit as st
2
+ from transformers import pipeline
3
 
4
+ classifier = pipeline("translation_en_to_fr",model="t5-base")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
5
  def main():
6
+ st.title("English to french")
7
+
8
+ with st.form("text_field"):
9
+ text = st.text_area('enter some text:')
10
+ # clicked==True only when the button is clicked
11
+ clicked = st.form_submit_button("Submit")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
12
  if clicked:
13
+ results = classifier([text])
14
+ st.json(results)
15
+
16
+ if __name__ == "__main__":
17
+ main()