allietran commited on
Commit
32bc000
·
verified ·
1 Parent(s): 2249692

Update README.md

Browse files
Files changed (1) hide show
  1. README.md +26 -6
README.md CHANGED
@@ -46,13 +46,33 @@ Script to download and use the dataset:
46
 
47
  ```python
48
  from datasets import load_dataset
 
 
 
 
49
 
50
- products = load_dataset("allietran/CAMEO", "products")
51
- reviews = load_dataset("allietran/CAMEO", "reviews")
 
52
 
53
- print(products["test"][0])
54
- print(reviews["test"][0])
55
 
56
- img = products["test"][0]["image_path"]
57
- print(type(img))
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
58
  ```
 
46
 
47
  ```python
48
  from datasets import load_dataset
49
+ from huggingface_hub import hf_hub_download
50
+ import os
51
+ from zipfile import ZipFile
52
+ from PIL import Image
53
 
54
+ # 1. Load products and reviews datasets
55
+ products = load_dataset("allietran/CAMEO", "products", split="test")
56
+ reviews = load_dataset("allietran/CAMEO", "reviews", split="test")
57
 
58
+ # 2. Download the images
59
+ zip_path = hf_hub_download(repo_id="allietran/CAMEO", filename="images.zip", repo_type="dataset")
60
 
61
+ # 3. Extract images to a local folder
62
+ extract_path = "./images"
63
+ with ZipFile(zip_path, 'r') as zip_ref:
64
+ zip_ref.extractall(extract_path)
65
+
66
+ # 4. Access a row
67
+ sample = products[0]
68
+ relative_path = sample["image_path"]
69
+
70
+ # 5. Open the image manually
71
+ full_path = os.path.join(extract_path, relative_path)
72
+
73
+ if os.path.exists(full_path):
74
+ img = Image.open(full_path)
75
+ img.show()
76
+ else:
77
+ print(f"File not found at: {full_path}")
78
  ```