Singularity666 commited on
Commit
328c388
·
1 Parent(s): c78a373

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +61 -57
app.py CHANGED
@@ -14,7 +14,6 @@ from io import BytesIO
14
  # Set up OpenAI API
15
  openai.api_key = "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"
16
 
17
- # Custom CSS for the page
18
  st.markdown(
19
  """
20
  <style>
@@ -46,19 +45,19 @@ st.markdown(
46
  border-radius: 5px; /* Add border-radius to the headers */
47
  }
48
  .feedback_button {
49
- font-size: 1.2em;
50
- padding: 8px 16px;
51
- border: none;
52
- border-radius: 8px;
53
- background: rgba(255, 255, 255, 0.7);
54
- box-shadow: 4px 4px 8px rgba(0, 0, 0, 0.1), -4px -4px 8px rgba(255, 255, 255, 0.7);
55
- color: #1c1c1c;
56
- cursor: pointer;
57
- transition: all 0.3s ease;
58
  }
59
  .feedback_button:hover {
60
- box-shadow: inset 2px 2px 4px rgba(0, 0, 0, 0.1), inset -2px -2px 4px rgba(255, 255, 255, 0.7);
61
- background: rgba(255, 255, 255, 0.9);
 
 
62
  }
63
  </style>
64
  """,
@@ -154,54 +153,59 @@ if uploaded_file is not None:
154
  st.write(radiology_report_with_personal_info)
155
  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)
156
 
157
- # Advanced Feedback System
158
- st.header("RadiXGPT Self-Adaptive Learning: Your Input Shapes Our AI")
159
-
160
- st.write("Help RadiXGPT improve its diagnostic capabilities by providing feedback on the generated report. Your input enables the AI to learn and adapt to specific medical terminology and imaging, ultimately leading to more accurate reports. ")
161
-
162
- st.markdown('<div style="text-align: center;"><p>Rate the generated report:</p>', unsafe_allow_html=True)
163
- col1, col2, col3 = st.beta_columns(3)
164
-
165
- with col1:
166
- st.write("")
167
- if st.button("Worse", key="worse", css_classes="feedback_button"):
168
- feedback = "Worse"
169
- else:
170
- feedback = None
171
-
172
- with col2:
173
- st.write("")
174
- if st.button("Satisfied", key="satisfied", css_classes="feedback_button"):
175
- feedback = "Satisfied"
176
- else:
177
- feedback = None
178
-
179
- with col3:
180
- st.write("")
181
- if st.button("Better", key="better", css_classes="feedback_button"):
182
- feedback = "Better"
183
- else:
184
- feedback = None
185
-
186
- if feedback is not None:
187
- if feedback == "Worse":
188
- with st.spinner("Regenerating Radiology Report..."):
189
- image_np = np.array(image)
190
- caption = show_predicted_caption(image_np)
191
- st.success(f"Caption: {caption}")
192
-
193
- # Generate the radiology report
194
  radiology_report = generate_radiology_report(f"Write Complete Radiology Report for this: {caption}")
195
-
196
- # Add personal information to the radiology report
197
  radiology_report_with_personal_info = f"Patient Name: {first_name} {last_name}\nAge: {age}\nGender: {gender}\n\n{radiology_report}"
198
-
199
  with container:
200
  st.header("Radiology Report")
201
  st.write(radiology_report_with_personal_info)
202
  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)
203
- else:
204
- st.success(f"Thank you for your feedback: {feedback}")
205
- # Add your feedback processing logic here
206
- # This could include updating the model with the new information,
207
- # logging the feedback, or triggering an alert for manual review
 
 
 
 
 
 
 
 
 
 
 
14
  # Set up OpenAI API
15
  openai.api_key = "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"
16
 
 
17
  st.markdown(
18
  """
19
  <style>
 
45
  border-radius: 5px; /* Add border-radius to the headers */
46
  }
47
  .feedback_button {
48
+ display: inline-block;
49
+ background-color: #e0e0e0;
50
+ padding: 10px;
51
+ margin: 5px;
52
+ border-radius: 10px;
53
+ box-shadow: 3px 3px 5px #bfbfbf, -3px -3px 5px #ffffff;
54
+ transition: box-shadow 0.3s ease;
 
 
55
  }
56
  .feedback_button:hover {
57
+ box-shadow: inset 3px 3px 5px #bfbfbf, inset -3px -3px 5px #ffffff;
58
+ }
59
+ .feedback_button:active {
60
+ box-shadow: inset 5px 5px 7px #bfbfbf, inset -5px -5px 7px #ffffff;
61
  }
62
  </style>
63
  """,
 
153
  st.write(radiology_report_with_personal_info)
154
  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)
155
 
156
+ ...
157
+ # Advanced Feedback System
158
+ st.header("Self-Adaptive Learning for Advanced AGI Radiology Feedback System")
159
+ st.markdown("Rate the generated report and help our AI evolve by providing feedback:")
160
+
161
+ # Load icons as base64
162
+ better_icon = "data:image/png;base64,iVBORw0KGg..."
163
+ satisfied_icon = "data:image/png;base64,iVBORw0KGg..."
164
+ worse_icon = "data:image/png;base64,iVBORw0KGg..."
165
+
166
+ # Custom feedback buttons with neumorphic design and icons
167
+ feedback_html = f"""
168
+ <div style="display: flex; justify-content: center;">
169
+ <div class="feedback_button" id="better_button" style="cursor:pointer;">
170
+ <img src="{better_icon}" width="30" height="30" alt="Better Icon">
171
+ <p>Better</p>
172
+ </div>
173
+ <div class="feedback_button" id="satisfied_button" style="cursor:pointer;">
174
+ <img src="{satisfied_icon}" width="30" height="30" alt="Satisfied Icon">
175
+ <p>Satisfied</p>
176
+ </div>
177
+ <div class="feedback_button" id="worse_button" style="cursor:pointer;">
178
+ <img src="{worse_icon}" width="30" height="30" alt="Worse Icon">
179
+ <p>Worse</p>
180
+ </div>
181
+ </div>
182
+ """
183
+
184
+ st.markdown(feedback_html, unsafe_allow_html=True)
185
+
186
+ # Define a function to handle feedback button clicks
187
+ def handle_feedback_button_click(feedback):
188
+ if feedback == 'worse':
189
+ # Regenerate and display the radiology report
 
 
 
190
  radiology_report = generate_radiology_report(f"Write Complete Radiology Report for this: {caption}")
 
 
191
  radiology_report_with_personal_info = f"Patient Name: {first_name} {last_name}\nAge: {age}\nGender: {gender}\n\n{radiology_report}"
192
+ container = st.container()
193
  with container:
194
  st.header("Radiology Report")
195
  st.write(radiology_report_with_personal_info)
196
  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)
197
+ # Implement other feedback handling logic here
198
+
199
+ # Capture feedback button clicks
200
+ with st.empty():
201
+ feedback_button_click = st.button("Better", key="better_button")
202
+ if feedback_button_click:
203
+ handle_feedback_button_click('better')
204
+
205
+ feedback_button_click = st.button("Satisfied", key="satisfied_button")
206
+ if feedback_button_click:
207
+ handle_feedback_button_click('satisfied')
208
+
209
+ feedback_button_click = st.button("Worse", key="worse_button")
210
+ if feedback_button_click:
211
+ handle_feedback_button_click('worse')