mo-mittal commited on
Commit
e2bf408
1 Parent(s): 017f762

Update reddit_political_subs.py

Browse files
Files changed (1) hide show
  1. reddit_political_subs.py +2 -15
reddit_political_subs.py CHANGED
@@ -39,7 +39,7 @@ class RedditPoliticalSubs(datasets.GeneratorBasedBuilder):
39
  "selftext_html": Value("string"),
40
  "author_flair_text": Value("string"),
41
  "link_flair_text": Value("string"),
42
- #"image": Image(),
43
  "image_text": Value("string"),
44
  }),
45
  supervised_keys=None,
@@ -61,19 +61,6 @@ class RedditPoliticalSubs(datasets.GeneratorBasedBuilder):
61
  df = pd.read_csv(dataframe_path)
62
 
63
  for idx, row in df.iterrows():
64
- # image_data = None
65
- # if pd.notna(row['url']):
66
- # try:
67
- # response = requests.get(row['url'])
68
- # response.raise_for_status()
69
- # image = PIL_Image.open(io.BytesIO(response.content))
70
- # image = PIL_Image.convert('RGB')
71
- # img_byte_arr = io.BytesIO()
72
- # image.save(img_byte_arr, format='JPEG')
73
- # image_data = img_byte_arr.getvalue()
74
- # except Exception as e:
75
- # logging.exception(f"Could not download or process image from {row['url']}: {e}")
76
- # image_data = None
77
 
78
  yield idx, {
79
  "author": row["author"],
@@ -96,6 +83,6 @@ class RedditPoliticalSubs(datasets.GeneratorBasedBuilder):
96
  "selftext_html": row["selftext_html"] if pd.notna(row["selftext_html"]) else "",
97
  "author_flair_text": row["author_flair_text"] if pd.notna(row["author_flair_text"]) else "",
98
  "link_flair_text": row["link_flair_text"] if pd.notna(row["link_flair_text"]) else "",
99
- #"image": row['url'],
100
  "image_text": row['image_text'] if pd.notna(row['image_text']) else "",
101
  }
 
39
  "selftext_html": Value("string"),
40
  "author_flair_text": Value("string"),
41
  "link_flair_text": Value("string"),
42
+ "image": Image(),
43
  "image_text": Value("string"),
44
  }),
45
  supervised_keys=None,
 
61
  df = pd.read_csv(dataframe_path)
62
 
63
  for idx, row in df.iterrows():
 
 
 
 
 
 
 
 
 
 
 
 
 
64
 
65
  yield idx, {
66
  "author": row["author"],
 
83
  "selftext_html": row["selftext_html"] if pd.notna(row["selftext_html"]) else "",
84
  "author_flair_text": row["author_flair_text"] if pd.notna(row["author_flair_text"]) else "",
85
  "link_flair_text": row["link_flair_text"] if pd.notna(row["link_flair_text"]) else "",
86
+ "image": row['url'] if pd.notna(row['url']) else "",
87
  "image_text": row['image_text'] if pd.notna(row['image_text']) else "",
88
  }