am commited on
Commit
e9ddefd
·
1 Parent(s): b86b064
Files changed (1) hide show
  1. app.py +41 -41
app.py CHANGED
@@ -83,7 +83,7 @@ def model_inference(
83
 
84
  with gr.Blocks() as demo:
85
 
86
- # gr.HTML('<h1 style="text-align:center; margin: 0.2em 0; color: green;">NV-Reason-CXR-3B Demo. Check out the model card details <a href="https://huggingface.co/nvidia/NV-Reason-CXR-3B" target="_blank">here</a>.</h1>')
87
  send_btn = gr.Button("Send", variant="primary", render=False)
88
  textbox = gr.Textbox(show_label=False, placeholder="Enter your text here and press ENTER", render=False, submit_btn="Send")
89
 
@@ -110,47 +110,47 @@ with gr.Blocks() as demo:
110
  )
111
  ex.dataset.show_label = False
112
 
113
- # with gr.Column(scale=2):
114
- # chat_interface = gr.ChatInterface(fn=model_inference,
115
- # type="messages",
116
- # chatbot=gr.Chatbot(type="messages", label="AI", render_markdown=True, sanitize_html=False, allow_tags=True, height='35vw', container=False, show_share_button=False),
117
- # textbox=textbox,
118
- # additional_inputs=image_input,
119
- # multimodal=False,
120
- # fill_height=False,
121
- # show_api=False,
122
- # )
123
- # gr.HTML('<span style="color:lightgray">Start with a full prompt: Find abnormalities and support devices.<br>\
124
- # Follow up with additial questions, such as Provide differentials or Write a structured report.<br>')
125
-
126
-
127
-
128
- # # Clear chat history when an example is selected (keep example-populated inputs intact)
129
- # ex.load_input_event.then(
130
- # lambda: ([], [], [], None),
131
- # None,
132
- # [chat_interface.chatbot, chat_interface.chatbot_state, chat_interface.chatbot_value, chat_interface.saved_input],
133
- # queue=False,
134
- # show_api=False,
135
- # )
136
 
137
- # # Clear chat history when a new image is uploaded via the image input
138
- # image_input.upload(
139
- # lambda: ([], [], [], None, DEFAULT_PROMPT),
140
- # None,
141
- # [chat_interface.chatbot, chat_interface.chatbot_state, chat_interface.chatbot_value, chat_interface.saved_input, textbox],
142
- # queue=False,
143
- # show_api=False,
144
- # )
145
-
146
- # # Clear everything on Clear button click
147
- # clear_btn.click(
148
- # lambda: ([], [], [], None, "", None),
149
- # None,
150
- # [chat_interface.chatbot, chat_interface.chatbot_state, chat_interface.chatbot_value, chat_interface.saved_input, textbox, image_input],
151
- # queue=False,
152
- # show_api=False,
153
- # )
154
 
155
 
156
 
 
83
 
84
  with gr.Blocks() as demo:
85
 
86
+ gr.HTML('<h1 style="text-align:center; margin: 0.2em 0; color: green;">NV-Reason-CXR-3B Demo. Check out the model card details <a href="https://huggingface.co/nvidia/NV-Reason-CXR-3B" target="_blank">here</a>.</h1>')
87
  send_btn = gr.Button("Send", variant="primary", render=False)
88
  textbox = gr.Textbox(show_label=False, placeholder="Enter your text here and press ENTER", render=False, submit_btn="Send")
89
 
 
110
  )
111
  ex.dataset.show_label = False
112
 
113
+ with gr.Column(scale=2):
114
+ chat_interface = gr.ChatInterface(fn=model_inference,
115
+ type="messages",
116
+ chatbot=gr.Chatbot(type="messages", label="AI", render_markdown=True, sanitize_html=False, allow_tags=True, height='35vw', container=False, show_share_button=False),
117
+ textbox=textbox,
118
+ additional_inputs=image_input,
119
+ multimodal=False,
120
+ fill_height=False,
121
+ show_api=False,
122
+ )
123
+ gr.HTML('<span style="color:lightgray">Start with a full prompt: Find abnormalities and support devices.<br>\
124
+ Follow up with additial questions, such as Provide differentials or Write a structured report.<br>')
125
+
126
+
127
+
128
+ # Clear chat history when an example is selected (keep example-populated inputs intact)
129
+ ex.load_input_event.then(
130
+ lambda: ([], [], [], None),
131
+ None,
132
+ [chat_interface.chatbot, chat_interface.chatbot_state, chat_interface.chatbot_value, chat_interface.saved_input],
133
+ queue=False,
134
+ show_api=False,
135
+ )
136
 
137
+ # Clear chat history when a new image is uploaded via the image input
138
+ image_input.upload(
139
+ lambda: ([], [], [], None, DEFAULT_PROMPT),
140
+ None,
141
+ [chat_interface.chatbot, chat_interface.chatbot_state, chat_interface.chatbot_value, chat_interface.saved_input, textbox],
142
+ queue=False,
143
+ show_api=False,
144
+ )
145
+
146
+ # Clear everything on Clear button click
147
+ clear_btn.click(
148
+ lambda: ([], [], [], None, "", None),
149
+ None,
150
+ [chat_interface.chatbot, chat_interface.chatbot_state, chat_interface.chatbot_value, chat_interface.saved_input, textbox, image_input],
151
+ queue=False,
152
+ show_api=False,
153
+ )
154
 
155
 
156