wintercoming6 commited on
Commit
f21a7cb
1 Parent(s): a18e5e8

Update artwork_for_sdxl.py

Browse files
Files changed (1) hide show
  1. artwork_for_sdxl.py +9 -4
artwork_for_sdxl.py CHANGED
@@ -34,7 +34,7 @@ Artwork Images, to generate the similar artwork using stable diffusion model.
34
  """
35
 
36
  _URL = "https://huggingface.co/datasets/wintercoming6/artwork_for_sdxl/resolve/main/metadata.jsonl"
37
- _image_url = "https://huggingface.co/datasets/wintercoming6/artwork_for_sdxl/resolve/main/images"
38
 
39
  class Artwork(datasets.GeneratorBasedBuilder):
40
  """Artwork Images - a dataset of centuries of Images prompt."""
@@ -55,8 +55,7 @@ class Artwork(datasets.GeneratorBasedBuilder):
55
  def _split_generators(self, dl_manager):
56
  data_files = dl_manager.download_and_extract(_URL)
57
  df = pd.read_json(data_files, lines=True)
58
- image_files = dl_manager.download_and_extract(_image_url)
59
- df['image'] = df['file_name'].apply(lambda x: os.path.join(image_files, x))
60
  return [
61
  datasets.SplitGenerator(
62
  name=datasets.Split.TRAIN,
@@ -65,6 +64,11 @@ class Artwork(datasets.GeneratorBasedBuilder):
65
  },
66
  ),
67
  ]
 
 
 
 
 
68
 
69
  def _generate_examples(self, files):
70
  cnt=0
@@ -78,7 +82,8 @@ class Artwork(datasets.GeneratorBasedBuilder):
78
  print(type(path.file_name))
79
  # print current os directory
80
  print(os.getcwd())
 
81
  yield {
82
  "prompt": path.prompt,
83
- "image_data": Image.open(path.image),
84
  }
 
34
  """
35
 
36
  _URL = "https://huggingface.co/datasets/wintercoming6/artwork_for_sdxl/resolve/main/metadata.jsonl"
37
+ _image_url = "https://huggingface.co/datasets/wintercoming6/artwork_for_sdxl/resolve/main/"
38
 
39
  class Artwork(datasets.GeneratorBasedBuilder):
40
  """Artwork Images - a dataset of centuries of Images prompt."""
 
55
  def _split_generators(self, dl_manager):
56
  data_files = dl_manager.download_and_extract(_URL)
57
  df = pd.read_json(data_files, lines=True)
58
+
 
59
  return [
60
  datasets.SplitGenerator(
61
  name=datasets.Split.TRAIN,
 
64
  },
65
  ),
66
  ]
67
+
68
+ def download_image(self, url):
69
+ response = requests.get(url)
70
+ img = Image.open(io.BytesIO(response.content))
71
+ return img
72
 
73
  def _generate_examples(self, files):
74
  cnt=0
 
82
  print(type(path.file_name))
83
  # print current os directory
84
  print(os.getcwd())
85
+ img = download_image(self, _image_url+ path.file_name)
86
  yield {
87
  "prompt": path.prompt,
88
+ "image_data": img,
89
  }