NativeVex commited on
Commit
87f6beb
1 Parent(s): bd93b63

dataframe prettied it up

Browse files
Files changed (3) hide show
  1. Dockerfile +1 -1
  2. docker-run.esh +1 -1
  3. language_models_project/app.py +7 -3
Dockerfile CHANGED
@@ -22,4 +22,4 @@ HEALTHCHECK CMD curl --fail http://localhost:8501/_stcore/health
22
 
23
  ADD . /app
24
  RUN pip3 install streamlit
25
- ENTRYPOINT ["streamlit", "run", "streamlit_app.py", "--server.port=8501", "--server.address=0.0.0.0"]
 
22
 
23
  ADD . /app
24
  RUN pip3 install streamlit
25
+ CMD ["streamlit", "run", "language_models_project/app.py", "--server.port=8501", "--server.address=0.0.0.0"]
docker-run.esh CHANGED
@@ -1 +1 @@
1
- (run-python "dtach -A /tmp/streamlit docker run -ti --rm -v .:/app -v /tmp:/tmp -p 10.147.17.74:6969:8501 streamlit /usr/local/bin/ipython")
 
1
+ (run-python "dtach -A /tmp/streamlit docker run -ti --rm -v .:/app -v /tmp:/tmp streamlit /usr/local/bin/ipython")
language_models_project/app.py CHANGED
@@ -70,7 +70,9 @@ def infer(text: str) -> List[Dict[str, float]]:
70
  predictions = np.zeros(probs.shape)
71
  predictions[np.where(probs >= 0.5)] = 1
72
  predictions = pd.Series(predictions == 1)
73
- predictions.index = [
 
 
74
  "toxic",
75
  "severe_toxic",
76
  "obscene",
@@ -78,7 +80,8 @@ def infer(text: str) -> List[Dict[str, float]]:
78
  "insult",
79
  "identity_hate",
80
  ]
81
- return [{"label": predictions, "score": probs}]
 
82
 
83
 
84
  def wrapper(*args, **kwargs):
@@ -109,7 +112,8 @@ if st.button("Classify"):
109
  "processed before displaying. Please allow a few minutes for longer"
110
  "inputs."
111
  )
112
- j = pd.DataFrame([infer(text=i) for i in data])
 
113
  st.dataframe(data=j)
114
 
115
 
 
70
  predictions = np.zeros(probs.shape)
71
  predictions[np.where(probs >= 0.5)] = 1
72
  predictions = pd.Series(predictions == 1)
73
+
74
+ l = pd.Series(zip(predictions.tolist(), probs.tolist()))
75
+ l.index = [
76
  "toxic",
77
  "severe_toxic",
78
  "obscene",
 
80
  "insult",
81
  "identity_hate",
82
  ]
83
+ #probs.index = predictions.index
84
+ return l.to_dict()
85
 
86
 
87
  def wrapper(*args, **kwargs):
 
112
  "processed before displaying. Please allow a few minutes for longer"
113
  "inputs."
114
  )
115
+ internal_list = [infer(text=i) for i in data]
116
+ j = pd.DataFrame(internal_list)
117
  st.dataframe(data=j)
118
 
119