fedric95 commited on
Commit
a0a907d
·
verified ·
1 Parent(s): aa34285

Delete harmonize.py

Browse files
Files changed (1) hide show
  1. harmonize.py +0 -56
harmonize.py DELETED
@@ -1,56 +0,0 @@
1
-
2
- from rasterio.enums import Resampling
3
- from huggingface_hub import hf_hub_download
4
- import pandas as pd
5
- import rasterio
6
- import matplotlib.pyplot as plt
7
-
8
- df = pd.read_excel('out.xlsx')
9
-
10
- records = []
11
- for index, row in df.iterrows():
12
- if row['crs'] == '+proj=longlat +datum=WGS84 +no_defs=True':
13
- records.append(row)
14
-
15
- for record in records:
16
-
17
- hf_hub_download(
18
- 'fedric95/umbra',
19
- './image/{id}.tiff'.format(id=record['id']),
20
- local_dir = 'dataset/',
21
- repo_type = 'dataset'
22
- )
23
- hf_hub_download(
24
- 'fedric95/umbra',
25
- './label/{id}.tiff'.format(id=record['id']),
26
- local_dir = 'dataset/',
27
- repo_type = 'dataset'
28
- )
29
-
30
- image = './dataset/image/{id}.tiff'.format(id=record['id'])
31
- label = './dataset/label/{id}.tiff'.format(id=record['id'])
32
-
33
- with rasterio.open(image) as image_src:
34
- with rasterio.open(label) as label_src:
35
-
36
- # resample data to target shape
37
- data = label_src.read(
38
- out_shape=(
39
- label_src.count,
40
- image_src.height,
41
- image_src.width
42
- ),
43
- resampling=Resampling.bilinear
44
- )
45
-
46
- # scale image transform
47
- transform = label_src.transform * label_src.transform.scale(
48
- (label_src.width / data.shape[-1]),
49
- (label_src.height / data.shape[-2])
50
- )
51
-
52
- import pdb
53
- pdb.set_trace()
54
-
55
- plt.imshow(data[0, :, :])
56
- plt.savefig('label.png')