Luigi commited on
Commit
e1ad065
·
1 Parent(s): c9c43a8

bugifx on ui about model selection

Browse files
Files changed (1) hide show
  1. app.py +33 -5
app.py CHANGED
@@ -144,12 +144,40 @@ def main():
144
  model_dd = gr.Dropdown(mf, value=mf[0], label='Decoder Weights')
145
  clip_dd = gr.Dropdown(cf, value=cf[0], label='CLIP Weights')
146
 
147
- # On any selection change, preload the llm
148
- size_dd.change(fn=lambda s, m, c: update_llm(s, m, c), inputs=[size_dd, model_dd, clip_dd], outputs=[])
149
- model_dd.change(fn=lambda s, m, c: update_llm(s, m, c), inputs=[size_dd, model_dd, clip_dd], outputs=[])
150
- clip_dd.change(fn=lambda s, m, c: update_llm(s, m, c), inputs=[size_dd, model_dd, clip_dd], outputs=[])
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
151
 
152
- # Initial load
 
 
 
153
  update_llm(default, mf[0], cf[0])
154
 
155
  interval = gr.Slider(100, 20000, step=100, value=3000, label='Interval (ms)')
 
144
  model_dd = gr.Dropdown(mf, value=mf[0], label='Decoder Weights')
145
  clip_dd = gr.Dropdown(cf, value=cf[0], label='CLIP Weights')
146
 
147
+ # When size changes: update dropdowns AND preload llm with the new first weights
148
+ def on_size_change(sz):
149
+ mlist, clist = get_weight_files(sz)
150
+ # update dropdown choices and default values
151
+ update_ui = (
152
+ gr.update(choices=mlist, value=mlist[0]),
153
+ gr.update(choices=clist, value=clist[0])
154
+ )
155
+ # preload with first weights
156
+ update_llm(sz, mlist[0], clist[0])
157
+ return update_ui
158
+ size_dd.change(
159
+ fn=on_size_change,
160
+ inputs=[size_dd],
161
+ outputs=[model_dd, clip_dd]
162
+ )
163
+
164
+ # When model weight changes: preload llm
165
+ model_dd.change(
166
+ fn=lambda sz, mf, cf: update_llm(sz, mf, cf),
167
+ inputs=[size_dd, model_dd, clip_dd],
168
+ outputs=[]
169
+ )
170
+ # When clip weight changes: preload llm
171
+ clip_dd.change(
172
+ fn=lambda sz, mf, cf: update_llm(sz, mf, cf),
173
+ inputs=[size_dd, model_dd, clip_dd],
174
+ outputs=[]
175
+ )
176
 
177
+ # Initial preload with defaults
178
+ update_llm(default, mf[0], cf[0])
179
+
180
+ interval = gr.Slider(100, 20000, step=100, value=3000, label='Interval (ms)')
181
  update_llm(default, mf[0], cf[0])
182
 
183
  interval = gr.Slider(100, 20000, step=100, value=3000, label='Interval (ms)')