shainaraza commited on
Commit
3483d1f
·
verified ·
1 Parent(s): f7febd7

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +12 -8
README.md CHANGED
@@ -96,6 +96,7 @@ import os
96
  from PIL import Image
97
 
98
  # Path to your dataset CSV and image folder
 
99
  dataset_csv_path = 'sample_dataset.csv'
100
  image_folder_path = 'sampled_images'
101
 
@@ -224,7 +225,7 @@ def generate_prediction(sample):
224
  samples = prepare_samples_from_dataframe(df, image_folder_path)
225
 
226
  # Limit to a subset if desired
227
- samples_to_infer = samples[:5] # For example, take the first 5 samples
228
 
229
  # Run inference and collect results
230
  results = []
@@ -232,26 +233,29 @@ results = []
232
  for sample in samples_to_infer:
233
  assistant_reply = generate_prediction(sample)
234
  predicted_label = extract_classification(assistant_reply)
235
-
 
 
236
  # Collect results
237
  result = {
238
- 'unique_id': sample['unique_id'],
239
- 'assistant_reply': assistant_reply,
240
- 'predicted_label': predicted_label,
241
- # Add any other fields you need from the sample or DataFrame
242
  }
243
  results.append(result)
244
 
245
  # Display the results
246
  print(f"Sample ID: {sample['unique_id']}")
 
247
  print("Assistant's Reply:")
248
  print(assistant_reply)
249
- print(f"Predicted Label: {predicted_label}")
250
  print("-" * 50)
251
 
252
  results_df = pd.DataFrame(results)
253
  # Save to CSV if desired
254
- results_df.to_csv('inference_results.csv', index=False)
255
  ```
256
  ### Example Output
257
 
 
96
  from PIL import Image
97
 
98
  # Path to your dataset CSV and image folder
99
+ # get our sample from here https://huggingface.co/vector-institute/Llama3.2-Multimodal-Newsmedia-Bias-Detector/tree/main/sampled-data
100
  dataset_csv_path = 'sample_dataset.csv'
101
  image_folder_path = 'sampled_images'
102
 
 
225
  samples = prepare_samples_from_dataframe(df, image_folder_path)
226
 
227
  # Limit to a subset if desired
228
+ samples_to_infer = samples[:900] # For example, take the first 5 samples
229
 
230
  # Run inference and collect results
231
  results = []
 
233
  for sample in samples_to_infer:
234
  assistant_reply = generate_prediction(sample)
235
  predicted_label = extract_classification(assistant_reply)
236
+ # Get the first_paragraph from the original DataFrame
237
+ original_row = df[df['unique_id'] == sample['unique_id']].iloc[0]
238
+ first_paragraph = original_row['first_paragraph']
239
  # Collect results
240
  result = {
241
+ 'unique_id': sample['unique_id'],
242
+ 'first_paragraph': first_paragraph, # Add this line
243
+ 'assistant_reply': assistant_reply,
244
+ 'predicted_label': predicted_label,
245
  }
246
  results.append(result)
247
 
248
  # Display the results
249
  print(f"Sample ID: {sample['unique_id']}")
250
+ print(f"text: {first_paragraph}")
251
  print("Assistant's Reply:")
252
  print(assistant_reply)
253
+ #print(f"Predicted Label: {predicted_label}")
254
  print("-" * 50)
255
 
256
  results_df = pd.DataFrame(results)
257
  # Save to CSV if desired
258
+ results_df.to_csv('llama-vision-ift-inference_results.csv', index=False)
259
  ```
260
  ### Example Output
261