ncoria commited on
Commit
504c8fc
·
verified ·
1 Parent(s): 3198317

update files with fixes

Browse files
Files changed (4) hide show
  1. apply_model.py +7 -5
  2. explore.py +2 -2
  3. get_llava_response.py +2 -2
  4. train_model.py +2 -2
apply_model.py CHANGED
@@ -60,7 +60,7 @@ st.title('batik: frame classifier')
60
 
61
  st.text("Upload files to apply trained classifier on.")
62
  with st.form('embedding_generation_settings'):
63
- seq_file = st.file_uploader("Choose a video file", type=['seq', 'mp4'], accept_multiple_files=False)
64
  annot_files = st.file_uploader("Choose an annotation File", type=['annot','csv'], accept_multiple_files=True)
65
  downsample_rate = st.number_input('Downsample Rate',value=4)
66
  submit_embed_settings = st.form_submit_button('Create Embeddings', type='secondary')
@@ -118,12 +118,14 @@ if st.session_state.embeddings_df is not None and svm_clf is not None:
118
  apply_model = st.form_submit_button("Apply Model")
119
 
120
  if apply_model:
121
- if 'Test' in st.session_state.embeddings_df.index:
122
- test_videos = True
123
- elif 'Images' in st.session_state.embeddings_df.index:
124
  test_videos = True
125
  else:
126
- test_videos = False
 
 
 
 
127
  kwargs = {'embeddings_df' : st.session_state.embeddings_df,
128
  'specified_classes' : specified_classes,
129
  'classes_to_remove' : None,
 
60
 
61
  st.text("Upload files to apply trained classifier on.")
62
  with st.form('embedding_generation_settings'):
63
+ seq_file = st.file_uploader("Choose a video file", type=['seq', 'mp4'])
64
  annot_files = st.file_uploader("Choose an annotation File", type=['annot','csv'], accept_multiple_files=True)
65
  downsample_rate = st.number_input('Downsample Rate',value=4)
66
  submit_embed_settings = st.form_submit_button('Create Embeddings', type='secondary')
 
118
  apply_model = st.form_submit_button("Apply Model")
119
 
120
  if apply_model:
121
+ if 'Test' in st.session_state.embeddings_df:
 
 
122
  test_videos = True
123
  else:
124
+ print(f'shape of df: {st.session_state.embeddings_df.shape[0]}')
125
+ test_videos_array = [True for i in range(st.session_state.embeddings_df.shape[0])]
126
+ st.session_state.embeddings_df['Test'] = test_videos_array
127
+ test_videos = True
128
+
129
  kwargs = {'embeddings_df' : st.session_state.embeddings_df,
130
  'specified_classes' : specified_classes,
131
  'classes_to_remove' : None,
explore.py CHANGED
@@ -177,7 +177,7 @@ st.subheader("generate or import embeddings")
177
 
178
  st.text("Upload files to generate embeddings.")
179
  with st.form('embedding_generation_settings'):
180
- seq_file = st.file_uploader("Choose a video file", type=['seq', 'mp4'], accept_multiple_files=False)
181
  annot_files = st.file_uploader("Choose an annotation File", type=['annot','csv'], accept_multiple_files=True)
182
  downsample_rate = st.number_input('Downsample Rate',value=4)
183
  submit_embed_settings = st.form_submit_button('Create Embeddings', type='secondary')
@@ -211,7 +211,7 @@ else:
211
  st.divider()
212
  st.subheader("provide video file if not yet already provided")
213
 
214
- uploaded_file = st.file_uploader("Choose a video file", type=['seq', 'mp4'], accept_multiple_files=False)
215
 
216
  st.divider()
217
  if st.session_state.embeddings_df is not None and (uploaded_file is not None or seq_file is not None):
 
177
 
178
  st.text("Upload files to generate embeddings.")
179
  with st.form('embedding_generation_settings'):
180
+ seq_file = st.file_uploader("Choose a video file", type=['seq', 'mp4'])
181
  annot_files = st.file_uploader("Choose an annotation File", type=['annot','csv'], accept_multiple_files=True)
182
  downsample_rate = st.number_input('Downsample Rate',value=4)
183
  submit_embed_settings = st.form_submit_button('Create Embeddings', type='secondary')
 
211
  st.divider()
212
  st.subheader("provide video file if not yet already provided")
213
 
214
+ uploaded_file = st.file_uploader("Choose a video file", type=['seq', 'mp4'])
215
 
216
  st.divider()
217
  if st.session_state.embeddings_df is not None and (uploaded_file is not None or seq_file is not None):
get_llava_response.py CHANGED
@@ -47,8 +47,8 @@ def load_llava_checkpoint_hf(model_path, hf_token):
47
  bnb_4bit_use_double_quant=True,
48
  bnb_4bit_quant_type='nf4'
49
  )
50
- tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=False)
51
- model = AutoModelForCausalLM.from_pretrained(model_path, low_cpu_mem_usage=True, **kwargs)
52
  mm_use_im_start_end = getattr(model.config, "mm_use_im_start_end", False)
53
  mm_use_im_patch_token = getattr(model.config, "mm_use_im_patch_token", True)
54
  if mm_use_im_patch_token:
 
47
  bnb_4bit_use_double_quant=True,
48
  bnb_4bit_quant_type='nf4'
49
  )
50
+ tokenizer = AutoTokenizer.from_pretrained(model_path, use_fast=False, token=hf_token)
51
+ model = AutoModelForCausalLM.from_pretrained(model_path, low_cpu_mem_usage=True, token=hf_token, **kwargs)
52
  mm_use_im_start_end = getattr(model.config, "mm_use_im_start_end", False)
53
  mm_use_im_patch_token = getattr(model.config, "mm_use_im_patch_token", True)
54
  if mm_use_im_patch_token:
train_model.py CHANGED
@@ -35,7 +35,7 @@ def get_train_test_split(train_embeds, numerical_labels, test_size=0.05, random_
35
  @st.cache_resource
36
  def train_model(X_train, y_train, random_state=42):
37
  # Train SVM Classifier
38
- svm_clf = SVC(kernel='rbf', random_state=random_state, probability=True)
39
  svm_clf.fit(X_train, y_train)
40
  return svm_clf
41
 
@@ -56,7 +56,7 @@ st.title('batik: frame classifier training')
56
 
57
  st.text("Upload files to train classifier on.")
58
  with st.form('embedding_generation_settings'):
59
- seq_file = st.file_uploader("Choose a .seq File", type=['seq'])
60
  annot_files = st.file_uploader("Choose an annotation File", type=['annot','csv'], accept_multiple_files=True)
61
  downsample_rate = st.number_input('Downsample Rate',value=4)
62
  submit_embed_settings = st.form_submit_button('Create Embeddings', type='secondary')
 
35
  @st.cache_resource
36
  def train_model(X_train, y_train, random_state=42):
37
  # Train SVM Classifier
38
+ svm_clf = SVC(kernel='rbf', random_state=random_state, probability=True, verbose=True)
39
  svm_clf.fit(X_train, y_train)
40
  return svm_clf
41
 
 
56
 
57
  st.text("Upload files to train classifier on.")
58
  with st.form('embedding_generation_settings'):
59
+ seq_file = st.file_uploader("Choose a video file", type=['seq', 'mp4'])
60
  annot_files = st.file_uploader("Choose an annotation File", type=['annot','csv'], accept_multiple_files=True)
61
  downsample_rate = st.number_input('Downsample Rate',value=4)
62
  submit_embed_settings = st.form_submit_button('Create Embeddings', type='secondary')