cathw commited on
Commit
6882ca6
1 Parent(s): f09ab08

Upload reddit_climate_comment.py

Browse files
Files changed (1) hide show
  1. reddit_climate_comment.py +6 -1
reddit_climate_comment.py CHANGED
@@ -5,6 +5,8 @@ from datasets import GeneratorBasedBuilder, Features, Value, Sequence, SplitGene
5
  import logging
6
  import pandas as pd
7
  from typing import Dict
 
 
8
 
9
  CITATION = ""
10
  _DESCRIPTION = "Demo"
@@ -68,6 +70,9 @@ class NewDataset(GeneratorBasedBuilder):
68
  post_body = post_data['PostBody']
69
  post_url = post_data['PostUrl']
70
  post_pic = post_data['PostPic']
 
 
 
71
  subreddit = post_data['Subreddit']
72
  post_timestamp = post_data['PostTimestamp']
73
  post_upvotes = post_data['PostUpvotes']
@@ -124,7 +129,7 @@ class NewDataset(GeneratorBasedBuilder):
124
  "post_author": post_author,
125
  "post_body": post_body,
126
  "post_url": post_url,
127
- "post_pic": post_pic,
128
  "subreddit": subreddit,
129
  "post_timestamp": post_timestamp,
130
  "post_upvotes": post_upvotes,
 
5
  import logging
6
  import pandas as pd
7
  from typing import Dict
8
+ import io
9
+ from PIL import Image as PILImage
10
 
11
  CITATION = ""
12
  _DESCRIPTION = "Demo"
 
70
  post_body = post_data['PostBody']
71
  post_url = post_data['PostUrl']
72
  post_pic = post_data['PostPic']
73
+ with io.BytesIO() as output:
74
+ post_pic.save(output, format="JPEG")
75
+ image_bytes = output.getvalue()
76
  subreddit = post_data['Subreddit']
77
  post_timestamp = post_data['PostTimestamp']
78
  post_upvotes = post_data['PostUpvotes']
 
129
  "post_author": post_author,
130
  "post_body": post_body,
131
  "post_url": post_url,
132
+ "post_pic": Image(image_bytes),
133
  "subreddit": subreddit,
134
  "post_timestamp": post_timestamp,
135
  "post_upvotes": post_upvotes,