Singularity666 commited on
Commit
cd22e2c
·
1 Parent(s): a06bc99

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +18 -26
app.py CHANGED
@@ -50,7 +50,6 @@ st.markdown(
50
  unsafe_allow_html=True,
51
  )
52
 
53
-
54
  device = torch.device("cpu")
55
 
56
  testing_df = pd.read_csv("testing_df.csv")
@@ -58,6 +57,12 @@ model = CLIPModel().to(device)
58
  model.load_state_dict(torch.load("weights.pt", map_location=torch.device('cpu')))
59
  text_embeddings = torch.load('saved_text_embeddings.pt', map_location=device)
60
 
 
 
 
 
 
 
61
  def show_predicted_caption(image):
62
  matches = predict_caption(
63
  image, model, text_embeddings, testing_df["caption"]
@@ -124,36 +129,23 @@ if uploaded_file is not None:
124
 
125
  # Generate the radiology report
126
  radiology_report = generate_radiology_report(f"Write Complete Radiology Report for this: {caption}")
127
-
128
  # Add personal information to the radiology report
129
  radiology_report_with_personal_info = f"Patient Name: {first_name} {last_name}\nAge: {age}\nGender: {gender}\n\n{radiology_report}"
130
-
131
  container = st.container()
132
  with container:
133
  st.header("Radiology Report")
134
  st.write(radiology_report_with_personal_info)
135
  st.markdown(download_link(save_as_docx(radiology_report_with_personal_info, "radiology_report.docx"), "radiology_report.docx", "Download Report as DOCX"), unsafe_allow_html=True)
136
 
137
- # Add the chatbot functionality
138
- st.header("1-to-1 Consultation")
139
- st.write("Ask any questions you have about the radiology report:")
140
-
141
- user_input = st.text_input("Enter your question:")
142
- chat_history = []
143
-
144
- if user_input:
145
- chat_history.append({"user": user_input})
146
-
147
- if user_input.lower() == "thank you":
148
- st.write("Bot: You're welcome! If you have any more questions, feel free to ask.")
149
- else:
150
- # Generate the answer to the user's question
151
- prompt = f"Answer to the user's question based on the generated radiology report: {user_input}"
152
- for history_item in chat_history:
153
- prompt += f"\nUser: {history_item['user']}"
154
- if 'bot' in history_item:
155
- prompt += f"\nBot: {history_item['bot']}"
156
-
157
- answer = chatbot_response(prompt)
158
- chat_history[-1]["bot"] = answer
159
- st.write(f"Bot: {answer}")
 
50
  unsafe_allow_html=True,
51
  )
52
 
 
53
  device = torch.device("cpu")
54
 
55
  testing_df = pd.read_csv("testing_df.csv")
 
57
  model.load_state_dict(torch.load("weights.pt", map_location=torch.device('cpu')))
58
  text_embeddings = torch.load('saved_text_embeddings.pt', map_location=device)
59
 
60
+ # Initialize the session state
61
+ if 'user_input' not in st.session_state:
62
+ st.session_state.user_input = ''
63
+ if 'chat_history' not in st.session_state:
64
+ st.session_state.chat_history = []
65
+
66
  def show_predicted_caption(image):
67
  matches = predict_caption(
68
  image, model, text_embeddings, testing_df["caption"]
 
129
 
130
  # Generate the radiology report
131
  radiology_report = generate_radiology_report(f"Write Complete Radiology Report for this: {caption}")
132
+
133
  # Add personal information to the radiology report
134
  radiology_report_with_personal_info = f"Patient Name: {first_name} {last_name}\nAge: {age}\nGender: {gender}\n\n{radiology_report}"
135
+
136
  container = st.container()
137
  with container:
138
  st.header("Radiology Report")
139
  st.write(radiology_report_with_personal_info)
140
  st.markdown(download_link(save_as_docx(radiology_report_with_personal_info, "radiology_report.docx"), "radiology_report.docx", "Download Report as DOCX"), unsafe_allow_html=True)
141
 
142
+ # Advanced Feedback System
143
+ st.header("Advanced Feedback System")
144
+ st.write("Provide feedback on the RadiXGPT system to help it learn and adapt to technical terms:")
145
+ feedback = st.text_area("Enter your feedback here...")
146
+
147
+ if st.button("Submit Feedback"):
148
+ st.success("Thank you for your feedback! Your input helps us improve the RadiXGPT system.")
149
+ # Add your feedback processing logic here
150
+ # This could include updating the model with the new information,
151
+ # logging the feedback, or triggering an alert for manual review