Datasets:
Upload folder using huggingface_hub
Browse filesThis view is limited to 50 files because it contains too many changes.
See raw diff
- .gitattributes +1 -0
- collect-hkm.py +68 -0
- images/hkm.00049815-1E48-4C06-8C23-C5C8DA9F11BA.jpg +3 -0
- images/hkm.000BC921-3333-425F-AD9D-4F6DF8F1F411.jpg +3 -0
- images/hkm.001AC4AD-E464-45E1-AE48-B2916B0F7524.jpg +3 -0
- images/hkm.001F7288-7A39-40E4-921C-4033293F73CD.jpg +3 -0
- images/hkm.003214A7-C9E3-4951-94E8-CEE331475A8C.jpg +3 -0
- images/hkm.004E3D8D-50E5-4B81-BD51-5A81FCA714C1.jpg +3 -0
- images/hkm.0069A920-2691-49D5-BE25-210129FC6D0A.jpg +3 -0
- images/hkm.006F286C-7241-4748-BACD-489C6ADA966D.jpg +3 -0
- images/hkm.00721F34-2A86-448E-881F-4EBA0327FB97.jpg +3 -0
- images/hkm.0083CA2B-02BF-409D-98E5-04A0E0453920.jpg +3 -0
- images/hkm.008E5E30-D694-436F-8B8A-C3717CD6B8C8.jpg +3 -0
- images/hkm.009E59F0-AB45-4C4E-8780-2ABB600FC6FE.jpg +3 -0
- images/hkm.00BE3BF4-DDF1-4D1E-9452-B9F4D50EB40C.jpg +3 -0
- images/hkm.00C06CBD-E131-45DA-9098-3ED818A585B7.jpg +3 -0
- images/hkm.00C752D8-9AA9-4E6D-BA00-A6F2E1EBF72C.jpg +3 -0
- images/hkm.00CB1696-837A-4384-8065-56F4AB6A1FE4.jpg +3 -0
- images/hkm.00CC9DF9-1FB8-4EF4-A98D-1306D48D5E01.jpg +3 -0
- images/hkm.00EC3CE5-83BD-42D7-9C8A-A1AC35A2F21C.jpg +3 -0
- images/hkm.00EF822A-3099-4D95-A7CF-A33C13018ED2.jpg +3 -0
- images/hkm.00F5B548-533E-4FCB-A0E2-2FB6346EA941.jpg +3 -0
- images/hkm.00F71433-FE53-49F4-BA19-62B2B6034385.jpg +3 -0
- images/hkm.00FB174C-B6BA-4D45-BC6B-FF54D100FB5A.jpg +3 -0
- images/hkm.010FE51C-4B74-49CE-88A7-C24C5F923EE5.jpg +3 -0
- images/hkm.011FA394-2B5D-48A1-B9AE-AEE6753221C7.jpg +3 -0
- images/hkm.012DA954-AEF5-44A4-8421-4F3D6BF3C3DF.jpg +3 -0
- images/hkm.01399904-4F0B-4805-874F-FC143482458D.jpg +3 -0
- images/hkm.013E0CE7-A27F-4992-B918-5A62CE90EBE0.jpg +3 -0
- images/hkm.014624B7-55D8-44F1-ADC7-2EBF8B949D30.jpg +3 -0
- images/hkm.0149F821-1BF5-4A07-8C3C-A50153A299EB.jpg +3 -0
- images/hkm.01613A3B-26BF-4157-BF37-E541A7C794D7.jpg +3 -0
- images/hkm.016D5459-E301-43B9-8989-E18D21DE1AAB.jpg +3 -0
- images/hkm.0172C85E-BDDE-40F8-AF57-3956C635B036.jpg +3 -0
- images/hkm.017AD274-A42E-42B5-AC00-A99190E90662.jpg +3 -0
- images/hkm.017C0614-4163-40A9-8E2A-133ABB97BD7B.jpg +3 -0
- images/hkm.01805E8E-2755-43E4-B9DB-53889287A7A9.jpg +3 -0
- images/hkm.0186A715-313F-4DF5-B87E-7F5622C91C8B.jpg +3 -0
- images/hkm.0199CC6B-4B90-4A03-88E8-2E9E41DCDF55.jpg +3 -0
- images/hkm.01A662EE-FC26-4445-8BC8-8A43F81DFB7F.jpg +3 -0
- images/hkm.01AA53A2-72CC-420E-9D88-ED64965A4049.jpg +3 -0
- images/hkm.01C0F957-A172-46A8-AE3F-9EFCBD9490FE.jpg +3 -0
- images/hkm.01CC675A-96BD-466B-AD4C-C7B806FBF954.jpg +3 -0
- images/hkm.01D21A8B-5EDC-4400-AABE-282E2B070138.jpg +3 -0
- images/hkm.01DFE437-53A6-469B-8C00-69931A2A6E97.jpg +3 -0
- images/hkm.01E0C8B0-1DC4-4ADF-9FC6-46EA3401E307.jpg +3 -0
- images/hkm.01FA3AAA-91CE-4532-AB45-E655DFBF5A84.jpg +3 -0
- images/hkm.02003654-0BCD-447B-9FF6-BD89BE783AA3.jpg +3 -0
- images/hkm.021af2db-7b12-4933-88fc-0fe62e74ebbc.jpg +3 -0
- images/hkm.0221F59E-6F33-49FB-9EAB-4E19F8E9F4CB.jpg +3 -0
.gitattributes
CHANGED
@@ -53,3 +53,4 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
|
53 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
54 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
55 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
|
|
|
53 |
*.jpg filter=lfs diff=lfs merge=lfs -text
|
54 |
*.jpeg filter=lfs diff=lfs merge=lfs -text
|
55 |
*.webp filter=lfs diff=lfs merge=lfs -text
|
56 |
+
metadata.jsonl filter=lfs diff=lfs merge=lfs -text
|
collect-hkm.py
ADDED
@@ -0,0 +1,68 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
1 |
+
#!/usr/bin/env python
|
2 |
+
|
3 |
+
from finna_client import FinnaClient, IMAGE_BASE
|
4 |
+
import requests
|
5 |
+
import json
|
6 |
+
import os
|
7 |
+
import os.path
|
8 |
+
import logging
|
9 |
+
|
10 |
+
finna = FinnaClient()
|
11 |
+
logging.basicConfig(format='%(asctime)s - %(message)s', level=logging.INFO)
|
12 |
+
|
13 |
+
MAX_YEAR = 1917 # retrieve only images older than this (inclusive)
|
14 |
+
IMAGE_DIR = 'images'
|
15 |
+
|
16 |
+
# Facet filters that define the set of images we want to
|
17 |
+
FILTERS = [
|
18 |
+
'~format_ext_str_mv:"1/Image/Photo/"', # Photographs
|
19 |
+
'~building:"0/HKM/"', # from HKM (Helsinki City Museum)
|
20 |
+
'~usage_rights_ext_str_mv:"0/B BY/"', # CC By license
|
21 |
+
f'search_daterange_mv:"overlap|[* TO {MAX_YEAR}]"', # date up to MAX_YEAR
|
22 |
+
]
|
23 |
+
|
24 |
+
# Fields to include in the metadata records
|
25 |
+
FIELDS = [
|
26 |
+
'formats',
|
27 |
+
'id',
|
28 |
+
'imageRights',
|
29 |
+
'images',
|
30 |
+
'languages',
|
31 |
+
'nonPresenterAuthors',
|
32 |
+
'onlineUrls',
|
33 |
+
'presenters',
|
34 |
+
'rating',
|
35 |
+
'series',
|
36 |
+
'subjects',
|
37 |
+
'title',
|
38 |
+
'year',
|
39 |
+
'rawData',
|
40 |
+
]
|
41 |
+
|
42 |
+
def download_url_to_file(url, filename):
|
43 |
+
if os.path.exists(filename) and os.stat(filename).st_size > 0:
|
44 |
+
return # file already exists, no need to re-download
|
45 |
+
with requests.get(url, stream=True) as r:
|
46 |
+
r.raise_for_status()
|
47 |
+
with open(filename, 'wb') as f:
|
48 |
+
for chunk in r.iter_content(chunk_size=8192):
|
49 |
+
f.write(chunk)
|
50 |
+
|
51 |
+
with open('metadata.jsonl', 'w') as outfile:
|
52 |
+
page = 1
|
53 |
+
|
54 |
+
while True:
|
55 |
+
logging.info(f'Loading result page {page}')
|
56 |
+
result = finna.search(filters=FILTERS, fields=FIELDS, page=page)
|
57 |
+
if 'records' not in result:
|
58 |
+
logging.info('No more records, stopping.')
|
59 |
+
break
|
60 |
+
logging.debug(f'Got {len(result["records"])} records')
|
61 |
+
for record in result['records']:
|
62 |
+
image_url = IMAGE_BASE + record['images'][0]
|
63 |
+
image_file_out = os.path.join(IMAGE_DIR, record['id'] + '.jpg')
|
64 |
+
download_url_to_file(image_url, image_file_out)
|
65 |
+
record['file_name'] = image_file_out
|
66 |
+
json.dump(record, outfile)
|
67 |
+
print("", file=outfile)
|
68 |
+
page += 1
|
images/hkm.00049815-1E48-4C06-8C23-C5C8DA9F11BA.jpg
ADDED
Git LFS Details
|
images/hkm.000BC921-3333-425F-AD9D-4F6DF8F1F411.jpg
ADDED
Git LFS Details
|
images/hkm.001AC4AD-E464-45E1-AE48-B2916B0F7524.jpg
ADDED
Git LFS Details
|
images/hkm.001F7288-7A39-40E4-921C-4033293F73CD.jpg
ADDED
Git LFS Details
|
images/hkm.003214A7-C9E3-4951-94E8-CEE331475A8C.jpg
ADDED
Git LFS Details
|
images/hkm.004E3D8D-50E5-4B81-BD51-5A81FCA714C1.jpg
ADDED
Git LFS Details
|
images/hkm.0069A920-2691-49D5-BE25-210129FC6D0A.jpg
ADDED
Git LFS Details
|
images/hkm.006F286C-7241-4748-BACD-489C6ADA966D.jpg
ADDED
Git LFS Details
|
images/hkm.00721F34-2A86-448E-881F-4EBA0327FB97.jpg
ADDED
Git LFS Details
|
images/hkm.0083CA2B-02BF-409D-98E5-04A0E0453920.jpg
ADDED
Git LFS Details
|
images/hkm.008E5E30-D694-436F-8B8A-C3717CD6B8C8.jpg
ADDED
Git LFS Details
|
images/hkm.009E59F0-AB45-4C4E-8780-2ABB600FC6FE.jpg
ADDED
Git LFS Details
|
images/hkm.00BE3BF4-DDF1-4D1E-9452-B9F4D50EB40C.jpg
ADDED
Git LFS Details
|
images/hkm.00C06CBD-E131-45DA-9098-3ED818A585B7.jpg
ADDED
Git LFS Details
|
images/hkm.00C752D8-9AA9-4E6D-BA00-A6F2E1EBF72C.jpg
ADDED
Git LFS Details
|
images/hkm.00CB1696-837A-4384-8065-56F4AB6A1FE4.jpg
ADDED
Git LFS Details
|
images/hkm.00CC9DF9-1FB8-4EF4-A98D-1306D48D5E01.jpg
ADDED
Git LFS Details
|
images/hkm.00EC3CE5-83BD-42D7-9C8A-A1AC35A2F21C.jpg
ADDED
Git LFS Details
|
images/hkm.00EF822A-3099-4D95-A7CF-A33C13018ED2.jpg
ADDED
Git LFS Details
|
images/hkm.00F5B548-533E-4FCB-A0E2-2FB6346EA941.jpg
ADDED
Git LFS Details
|
images/hkm.00F71433-FE53-49F4-BA19-62B2B6034385.jpg
ADDED
Git LFS Details
|
images/hkm.00FB174C-B6BA-4D45-BC6B-FF54D100FB5A.jpg
ADDED
Git LFS Details
|
images/hkm.010FE51C-4B74-49CE-88A7-C24C5F923EE5.jpg
ADDED
Git LFS Details
|
images/hkm.011FA394-2B5D-48A1-B9AE-AEE6753221C7.jpg
ADDED
Git LFS Details
|
images/hkm.012DA954-AEF5-44A4-8421-4F3D6BF3C3DF.jpg
ADDED
Git LFS Details
|
images/hkm.01399904-4F0B-4805-874F-FC143482458D.jpg
ADDED
Git LFS Details
|
images/hkm.013E0CE7-A27F-4992-B918-5A62CE90EBE0.jpg
ADDED
Git LFS Details
|
images/hkm.014624B7-55D8-44F1-ADC7-2EBF8B949D30.jpg
ADDED
Git LFS Details
|
images/hkm.0149F821-1BF5-4A07-8C3C-A50153A299EB.jpg
ADDED
Git LFS Details
|
images/hkm.01613A3B-26BF-4157-BF37-E541A7C794D7.jpg
ADDED
Git LFS Details
|
images/hkm.016D5459-E301-43B9-8989-E18D21DE1AAB.jpg
ADDED
Git LFS Details
|
images/hkm.0172C85E-BDDE-40F8-AF57-3956C635B036.jpg
ADDED
Git LFS Details
|
images/hkm.017AD274-A42E-42B5-AC00-A99190E90662.jpg
ADDED
Git LFS Details
|
images/hkm.017C0614-4163-40A9-8E2A-133ABB97BD7B.jpg
ADDED
Git LFS Details
|
images/hkm.01805E8E-2755-43E4-B9DB-53889287A7A9.jpg
ADDED
Git LFS Details
|
images/hkm.0186A715-313F-4DF5-B87E-7F5622C91C8B.jpg
ADDED
Git LFS Details
|
images/hkm.0199CC6B-4B90-4A03-88E8-2E9E41DCDF55.jpg
ADDED
Git LFS Details
|
images/hkm.01A662EE-FC26-4445-8BC8-8A43F81DFB7F.jpg
ADDED
Git LFS Details
|
images/hkm.01AA53A2-72CC-420E-9D88-ED64965A4049.jpg
ADDED
Git LFS Details
|
images/hkm.01C0F957-A172-46A8-AE3F-9EFCBD9490FE.jpg
ADDED
Git LFS Details
|
images/hkm.01CC675A-96BD-466B-AD4C-C7B806FBF954.jpg
ADDED
Git LFS Details
|
images/hkm.01D21A8B-5EDC-4400-AABE-282E2B070138.jpg
ADDED
Git LFS Details
|
images/hkm.01DFE437-53A6-469B-8C00-69931A2A6E97.jpg
ADDED
Git LFS Details
|
images/hkm.01E0C8B0-1DC4-4ADF-9FC6-46EA3401E307.jpg
ADDED
Git LFS Details
|
images/hkm.01FA3AAA-91CE-4532-AB45-E655DFBF5A84.jpg
ADDED
Git LFS Details
|
images/hkm.02003654-0BCD-447B-9FF6-BD89BE783AA3.jpg
ADDED
Git LFS Details
|
images/hkm.021af2db-7b12-4933-88fc-0fe62e74ebbc.jpg
ADDED
Git LFS Details
|
images/hkm.0221F59E-6F33-49FB-9EAB-4E19F8E9F4CB.jpg
ADDED
Git LFS Details
|