Datasets:
Upload README.md with huggingface_hub
Browse files
README.md
CHANGED
|
@@ -15,7 +15,7 @@ tags:
|
|
| 15 |
- pdf
|
| 16 |
- research
|
| 17 |
size_categories:
|
| 18 |
-
-
|
| 19 |
---
|
| 20 |
|
| 21 |
# CVPR Papers
|
|
@@ -102,62 +102,60 @@ CVPR_Papers/
|
|
| 102 |
### Installation
|
| 103 |
|
| 104 |
```bash
|
| 105 |
-
pip install huggingface_hub
|
| 106 |
```
|
| 107 |
|
| 108 |
-
###
|
| 109 |
-
|
| 110 |
-
Download a specific year from Hugging Face:
|
| 111 |
|
| 112 |
```python
|
| 113 |
-
from huggingface_hub import
|
|
|
|
| 114 |
|
| 115 |
-
# Download a specific year
|
| 116 |
year = "2013"
|
| 117 |
-
|
| 118 |
repo_id="choucsan/CVPR_Papers",
|
|
|
|
| 119 |
repo_type="dataset",
|
| 120 |
-
local_dir="CVPR_Papers",
|
| 121 |
-
allow_patterns=[f"{year}/*"],
|
| 122 |
)
|
| 123 |
-
```
|
| 124 |
-
|
| 125 |
-
### Load Data
|
| 126 |
-
|
| 127 |
-
```python
|
| 128 |
-
import json
|
| 129 |
|
| 130 |
-
# Load metadata
|
| 131 |
-
year = "2013"
|
| 132 |
papers = []
|
| 133 |
-
with open(
|
| 134 |
for line in f:
|
| 135 |
papers.append(json.loads(line))
|
| 136 |
|
| 137 |
print(f"Loaded {len(papers)} CVPR {year} papers")
|
| 138 |
-
|
| 139 |
-
# View first paper
|
| 140 |
-
first_paper = papers[0]
|
| 141 |
-
print(f"Title: {first_paper['title']}")
|
| 142 |
-
print(f"Authors: {first_paper['authors']}")
|
| 143 |
-
print(f"Abstract: {first_paper['abstract'][:200]}...")
|
| 144 |
```
|
| 145 |
|
| 146 |
### Download PDF Files
|
| 147 |
|
|
|
|
|
|
|
| 148 |
```python
|
| 149 |
import requests
|
|
|
|
|
|
|
|
|
|
|
|
|
| 150 |
|
| 151 |
-
# Download a specific paper
|
| 152 |
paper = papers[0]
|
| 153 |
response = requests.get(paper['download_url'])
|
| 154 |
|
| 155 |
-
|
| 156 |
-
|
| 157 |
-
with open(filename, 'wb') as f:
|
| 158 |
f.write(response.content)
|
| 159 |
|
| 160 |
print(f"Downloaded: {filename}")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 161 |
```
|
| 162 |
|
| 163 |
---
|
|
|
|
| 15 |
- pdf
|
| 16 |
- research
|
| 17 |
size_categories:
|
| 18 |
+
- 10K<n<100K
|
| 19 |
---
|
| 20 |
|
| 21 |
# CVPR Papers
|
|
|
|
| 102 |
### Installation
|
| 103 |
|
| 104 |
```bash
|
| 105 |
+
pip install huggingface_hub requests
|
| 106 |
```
|
| 107 |
|
| 108 |
+
### Load Metadata
|
|
|
|
|
|
|
| 109 |
|
| 110 |
```python
|
| 111 |
+
from huggingface_hub import hf_hub_download
|
| 112 |
+
import json
|
| 113 |
|
| 114 |
+
# Download metadata for a specific year
|
| 115 |
year = "2013"
|
| 116 |
+
meta_path = hf_hub_download(
|
| 117 |
repo_id="choucsan/CVPR_Papers",
|
| 118 |
+
filename=f"{year}/meta.jsonl",
|
| 119 |
repo_type="dataset",
|
|
|
|
|
|
|
| 120 |
)
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 121 |
|
| 122 |
+
# Load metadata
|
|
|
|
| 123 |
papers = []
|
| 124 |
+
with open(meta_path, 'r', encoding='utf-8') as f:
|
| 125 |
for line in f:
|
| 126 |
papers.append(json.loads(line))
|
| 127 |
|
| 128 |
print(f"Loaded {len(papers)} CVPR {year} papers")
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 129 |
```
|
| 130 |
|
| 131 |
### Download PDF Files
|
| 132 |
|
| 133 |
+
Each paper has a `download_url` field pointing to the original PDF on CVF Open Access:
|
| 134 |
+
|
| 135 |
```python
|
| 136 |
import requests
|
| 137 |
+
import os
|
| 138 |
+
|
| 139 |
+
# Create output directory
|
| 140 |
+
os.makedirs(f"cvpr_{year}_pdfs", exist_ok=True)
|
| 141 |
|
| 142 |
+
# Download a specific paper
|
| 143 |
paper = papers[0]
|
| 144 |
response = requests.get(paper['download_url'])
|
| 145 |
|
| 146 |
+
filename = os.path.basename(paper['pdf_path'])
|
| 147 |
+
with open(f"cvpr_{year}_pdfs/{filename}", 'wb') as f:
|
|
|
|
| 148 |
f.write(response.content)
|
| 149 |
|
| 150 |
print(f"Downloaded: {filename}")
|
| 151 |
+
|
| 152 |
+
# Download all papers for a year (optional)
|
| 153 |
+
for paper in papers:
|
| 154 |
+
if paper.get('download_url'):
|
| 155 |
+
response = requests.get(paper['download_url'])
|
| 156 |
+
filename = os.path.basename(paper['pdf_path'])
|
| 157 |
+
with open(f"cvpr_{year}_pdfs/{filename}", 'wb') as f:
|
| 158 |
+
f.write(response.content)
|
| 159 |
```
|
| 160 |
|
| 161 |
---
|