Commit
·
9904b3b
1
Parent(s):
e86180f
commit files to HF hub
Browse files- .gitattributes +0 -35
- .gitignore +0 -1
- README.md +0 -64
- config.json +0 -72
- filter.ipynb +0 -308
- pytorch_model.bin +0 -3
- training_args.bin +0 -3
.gitattributes
DELETED
@@ -1,35 +0,0 @@
|
|
1 |
-
*.7z filter=lfs diff=lfs merge=lfs -text
|
2 |
-
*.arrow filter=lfs diff=lfs merge=lfs -text
|
3 |
-
*.bin filter=lfs diff=lfs merge=lfs -text
|
4 |
-
*.bz2 filter=lfs diff=lfs merge=lfs -text
|
5 |
-
*.ckpt filter=lfs diff=lfs merge=lfs -text
|
6 |
-
*.ftz filter=lfs diff=lfs merge=lfs -text
|
7 |
-
*.gz filter=lfs diff=lfs merge=lfs -text
|
8 |
-
*.h5 filter=lfs diff=lfs merge=lfs -text
|
9 |
-
*.joblib filter=lfs diff=lfs merge=lfs -text
|
10 |
-
*.lfs.* filter=lfs diff=lfs merge=lfs -text
|
11 |
-
*.mlmodel filter=lfs diff=lfs merge=lfs -text
|
12 |
-
*.model filter=lfs diff=lfs merge=lfs -text
|
13 |
-
*.msgpack filter=lfs diff=lfs merge=lfs -text
|
14 |
-
*.npy filter=lfs diff=lfs merge=lfs -text
|
15 |
-
*.npz filter=lfs diff=lfs merge=lfs -text
|
16 |
-
*.onnx filter=lfs diff=lfs merge=lfs -text
|
17 |
-
*.ot filter=lfs diff=lfs merge=lfs -text
|
18 |
-
*.parquet filter=lfs diff=lfs merge=lfs -text
|
19 |
-
*.pb filter=lfs diff=lfs merge=lfs -text
|
20 |
-
*.pickle filter=lfs diff=lfs merge=lfs -text
|
21 |
-
*.pkl filter=lfs diff=lfs merge=lfs -text
|
22 |
-
*.pt filter=lfs diff=lfs merge=lfs -text
|
23 |
-
*.pth filter=lfs diff=lfs merge=lfs -text
|
24 |
-
*.rar filter=lfs diff=lfs merge=lfs -text
|
25 |
-
*.safetensors filter=lfs diff=lfs merge=lfs -text
|
26 |
-
saved_model/**/* filter=lfs diff=lfs merge=lfs -text
|
27 |
-
*.tar.* filter=lfs diff=lfs merge=lfs -text
|
28 |
-
*.tar filter=lfs diff=lfs merge=lfs -text
|
29 |
-
*.tflite filter=lfs diff=lfs merge=lfs -text
|
30 |
-
*.tgz filter=lfs diff=lfs merge=lfs -text
|
31 |
-
*.wasm filter=lfs diff=lfs merge=lfs -text
|
32 |
-
*.xz filter=lfs diff=lfs merge=lfs -text
|
33 |
-
*.zip filter=lfs diff=lfs merge=lfs -text
|
34 |
-
*.zst filter=lfs diff=lfs merge=lfs -text
|
35 |
-
*tfevents* filter=lfs diff=lfs merge=lfs -text
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
.gitignore
DELETED
@@ -1 +0,0 @@
|
|
1 |
-
checkpoint-*/
|
|
|
|
README.md
DELETED
@@ -1,64 +0,0 @@
|
|
1 |
-
---
|
2 |
-
base_model: ''
|
3 |
-
tags:
|
4 |
-
- generated_from_trainer
|
5 |
-
model-index:
|
6 |
-
- name: glacformer
|
7 |
-
results: []
|
8 |
-
---
|
9 |
-
|
10 |
-
<!-- This model card has been generated automatically according to the information the Trainer had access to. You
|
11 |
-
should probably proofread and complete it, then remove this comment. -->
|
12 |
-
|
13 |
-
# glacformer
|
14 |
-
|
15 |
-
This model is a fine-tuned version of [](https://huggingface.co/) on the None dataset.
|
16 |
-
It achieves the following results on the evaluation set:
|
17 |
-
- Loss: 0.0333
|
18 |
-
- Mean Iou: 0.9528
|
19 |
-
- Mean Accuracy: 0.9772
|
20 |
-
- Overall Accuracy: 0.9885
|
21 |
-
- Per Category Iou: [0.9855230058020051, 0.8845759711828091, 0.9883964861024538]
|
22 |
-
- Per Category Accuracy: [0.9921669407092866, 0.9462930795421282, 0.9931901963885149]
|
23 |
-
|
24 |
-
## Model description
|
25 |
-
|
26 |
-
More information needed
|
27 |
-
|
28 |
-
## Intended uses & limitations
|
29 |
-
|
30 |
-
More information needed
|
31 |
-
|
32 |
-
## Training and evaluation data
|
33 |
-
|
34 |
-
More information needed
|
35 |
-
|
36 |
-
## Training procedure
|
37 |
-
|
38 |
-
### Training hyperparameters
|
39 |
-
|
40 |
-
The following hyperparameters were used during training:
|
41 |
-
- learning_rate: 6e-05
|
42 |
-
- train_batch_size: 4
|
43 |
-
- eval_batch_size: 1
|
44 |
-
- seed: 42
|
45 |
-
- gradient_accumulation_steps: 4
|
46 |
-
- total_train_batch_size: 16
|
47 |
-
- optimizer: Adam with betas=(0.9,0.999) and epsilon=1e-08
|
48 |
-
- lr_scheduler_type: linear
|
49 |
-
- num_epochs: 2
|
50 |
-
|
51 |
-
### Training results
|
52 |
-
|
53 |
-
| Training Loss | Epoch | Step | Validation Loss | Mean Iou | Mean Accuracy | Overall Accuracy | Per Category Iou | Per Category Accuracy |
|
54 |
-
|:-------------:|:-----:|:----:|:---------------:|:--------:|:-------------:|:----------------:|:------------------------------------------------------------:|:------------------------------------------------------------:|
|
55 |
-
| 0.045 | 1.0 | 523 | 0.0421 | 0.9477 | 0.9795 | 0.9869 | [0.9852157890390353, 0.8719898483736556, 0.9857700613925825] | [0.9904340924248899, 0.9587586082053337, 0.9893900149083925] |
|
56 |
-
| 0.0372 | 2.0 | 1046 | 0.0333 | 0.9528 | 0.9772 | 0.9885 | [0.9855230058020051, 0.8845759711828091, 0.9883964861024538] | [0.9921669407092866, 0.9462930795421282, 0.9931901963885149] |
|
57 |
-
|
58 |
-
|
59 |
-
### Framework versions
|
60 |
-
|
61 |
-
- Transformers 4.31.0
|
62 |
-
- Pytorch 1.14.0.dev20221130+cu117
|
63 |
-
- Datasets 2.13.1
|
64 |
-
- Tokenizers 0.13.3
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
config.json
DELETED
@@ -1,72 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"architectures": [
|
3 |
-
"SegformerForSemanticSegmentation"
|
4 |
-
],
|
5 |
-
"attention_probs_dropout_prob": 0.0,
|
6 |
-
"classifier_dropout_prob": 0.1,
|
7 |
-
"decoder_hidden_size": 768,
|
8 |
-
"depths": [
|
9 |
-
2,
|
10 |
-
3,
|
11 |
-
4,
|
12 |
-
3
|
13 |
-
],
|
14 |
-
"drop_path_rate": 0.1,
|
15 |
-
"hidden_act": "gelu",
|
16 |
-
"hidden_dropout_prob": 0.0,
|
17 |
-
"hidden_sizes": [
|
18 |
-
64,
|
19 |
-
128,
|
20 |
-
320,
|
21 |
-
512
|
22 |
-
],
|
23 |
-
"id2label": {
|
24 |
-
"0": "sky",
|
25 |
-
"1": "surface-to-bed",
|
26 |
-
"2": "bed-to-bottom"
|
27 |
-
},
|
28 |
-
"initializer_range": 0.02,
|
29 |
-
"label2id": {
|
30 |
-
"bed-to-bottom": 2,
|
31 |
-
"sky": 0,
|
32 |
-
"surface-to-bed": 1
|
33 |
-
},
|
34 |
-
"layer_norm_eps": 1e-06,
|
35 |
-
"mlp_ratios": [
|
36 |
-
4,
|
37 |
-
4,
|
38 |
-
4,
|
39 |
-
4
|
40 |
-
],
|
41 |
-
"model_type": "segformer",
|
42 |
-
"num_attention_heads": [
|
43 |
-
1,
|
44 |
-
2,
|
45 |
-
5,
|
46 |
-
8
|
47 |
-
],
|
48 |
-
"num_channels": 3,
|
49 |
-
"num_encoder_blocks": 4,
|
50 |
-
"patch_sizes": [
|
51 |
-
7,
|
52 |
-
3,
|
53 |
-
3,
|
54 |
-
3
|
55 |
-
],
|
56 |
-
"reshape_last_stage": true,
|
57 |
-
"semantic_loss_ignore_index": 255,
|
58 |
-
"sr_ratios": [
|
59 |
-
8,
|
60 |
-
4,
|
61 |
-
2,
|
62 |
-
1
|
63 |
-
],
|
64 |
-
"strides": [
|
65 |
-
4,
|
66 |
-
2,
|
67 |
-
2,
|
68 |
-
2
|
69 |
-
],
|
70 |
-
"torch_dtype": "float32",
|
71 |
-
"transformers_version": "4.32.1"
|
72 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
filter.ipynb
DELETED
@@ -1,308 +0,0 @@
|
|
1 |
-
{
|
2 |
-
"cells": [
|
3 |
-
{
|
4 |
-
"cell_type": "code",
|
5 |
-
"execution_count": 2,
|
6 |
-
"metadata": {},
|
7 |
-
"outputs": [],
|
8 |
-
"source": [
|
9 |
-
"# Importing all required libraries\n",
|
10 |
-
"\n",
|
11 |
-
"# these are needed for path processing \n",
|
12 |
-
"import os\n",
|
13 |
-
"import pathlib as pl\n",
|
14 |
-
"\n",
|
15 |
-
"#image processing and display\n",
|
16 |
-
"import numpy as np\n",
|
17 |
-
"import PIL\n",
|
18 |
-
"import PIL.Image as Image\n",
|
19 |
-
"import PIL.ImageDraw as ImageDraw\n",
|
20 |
-
"import matplotlib.pyplot as plt\n",
|
21 |
-
"\n",
|
22 |
-
"#these are needed for data processing\n",
|
23 |
-
"import pandas as pd"
|
24 |
-
]
|
25 |
-
},
|
26 |
-
{
|
27 |
-
"cell_type": "code",
|
28 |
-
"execution_count": 17,
|
29 |
-
"metadata": {},
|
30 |
-
"outputs": [
|
31 |
-
{
|
32 |
-
"name": "stderr",
|
33 |
-
"output_type": "stream",
|
34 |
-
"text": [
|
35 |
-
"UsageError: Line magic function `%%script` not found.\n"
|
36 |
-
]
|
37 |
-
}
|
38 |
-
],
|
39 |
-
"source": [
|
40 |
-
"# This is the first step of the process. Once you have the images and csvs organized in folders with their names, you need to create the offset file that contains the offset. This code creates the offset file if it doesn't exist\n",
|
41 |
-
"\n",
|
42 |
-
"testset = os.listdir(\"secondleg\")[8]\n",
|
43 |
-
"print(testset)\n",
|
44 |
-
"tiff = Image.open(pl.Path(\n",
|
45 |
-
" rf'.\\secondleg\\{testset}\\{testset}.tiff')) \n",
|
46 |
-
"csv = pd.read_csv(pl.Path(\n",
|
47 |
-
" rf'.\\secondleg\\{testset}\\{testset}.csv')) \n",
|
48 |
-
"with open(pl.Path( \n",
|
49 |
-
" rf'.\\secondleg\\{testset}\\offset.txt'),\"+x\") as f: \n",
|
50 |
-
" offset = f.read() \n",
|
51 |
-
" if offset != '':\n",
|
52 |
-
" offset = int(offset)\n",
|
53 |
-
" else:\n",
|
54 |
-
" offset = 0\n"
|
55 |
-
]
|
56 |
-
},
|
57 |
-
{
|
58 |
-
"cell_type": "code",
|
59 |
-
"execution_count": null,
|
60 |
-
"metadata": {},
|
61 |
-
"outputs": [],
|
62 |
-
"source": [
|
63 |
-
"# This is a helper method for chopping up a large glacial scope image into smaller chunks with a width of parameter length and a certain amount of overlap\n",
|
64 |
-
"# Length is the length of the desired chunk, overlap is how much overlap there should be\n",
|
65 |
-
"def window_with_remainder(length, overlap, input_size):\n",
|
66 |
-
" testarray = np.arange(0, input_size)\n",
|
67 |
-
" return np.vstack((testarray[0:length], np.lib.stride_tricks.sliding_window_view(testarray[len(testarray) % length:], length)[::overlap]))[:, [0, -1]] + [0, 1]"
|
68 |
-
]
|
69 |
-
},
|
70 |
-
{
|
71 |
-
"cell_type": "code",
|
72 |
-
"execution_count": null,
|
73 |
-
"metadata": {},
|
74 |
-
"outputs": [],
|
75 |
-
"source": [
|
76 |
-
"# This code draws a rectangle from (40,0) to (100, y_surface) in green, and from (40, y_surface) to (100, y_bed) in white.\n",
|
77 |
-
"# The y_surface and y_bed variables are read from the csv file, and the csv file is read in as a pandas dataframe.\n",
|
78 |
-
"# The first 5 rows of the csv file are also printed.\n",
|
79 |
-
"# this is done to help calibrate the offsets by allowing the user to manually calibrate the offset for an image and move through the dataset through altering the listdir line through changing the index\n",
|
80 |
-
"\n",
|
81 |
-
"testset = os.listdir(\"secondleg\")[10]\n",
|
82 |
-
"print(testset)\n",
|
83 |
-
"\n",
|
84 |
-
"# opens the images, csvs and offset files and reads the needed data\n",
|
85 |
-
"tiff = Image.open(pl.Path(\n",
|
86 |
-
" rf'.\\secondleg\\{testset}\\{testset}.tiff'))\n",
|
87 |
-
"csv = pd.read_csv(pl.Path(\n",
|
88 |
-
" rf'.\\secondleg\\{testset}\\{testset}.csv'))\n",
|
89 |
-
"with open(pl.Path(\n",
|
90 |
-
" rf'.\\secondleg\\{testset}\\offset.txt')) as f:\n",
|
91 |
-
" offset = f.read()\n",
|
92 |
-
" if offset == \"\":\n",
|
93 |
-
" offset = 0\n",
|
94 |
-
" else:\n",
|
95 |
-
" offset = int(offset)\n",
|
96 |
-
"\n",
|
97 |
-
"# prints the current offset\n",
|
98 |
-
"\n",
|
99 |
-
"print(offset)\n",
|
100 |
-
"\n",
|
101 |
-
"# There is no need to open up the entire image, so we make a copy and chop it up\n",
|
102 |
-
"img = tiff.copy()\n",
|
103 |
-
"img = img.crop((0,430,img.size[0],1790)) \n",
|
104 |
-
"\n",
|
105 |
-
"print(csv.head()) # prints first 5 rows of csv file\n",
|
106 |
-
"csv = csv[[\"x_surface\", \"y_surface\", \"x_bed\", \"y_bed\"]]+offset\n",
|
107 |
-
"# the CSV is backwards, so i am accouting for this and getting up the first mask data point\n",
|
108 |
-
"line = csv.iloc[-1] # gets last row of csv file\n",
|
109 |
-
"print(csv.head()) # prints first 5 rows of csv file to make sure that the offeset was applied properly\n",
|
110 |
-
"\n",
|
111 |
-
"# creates the image masks and shows the image for calibration\n",
|
112 |
-
"draw = ImageDraw.Draw(img)\n",
|
113 |
-
"draw.rectangle([(40, 0), (100, line[\"y_surface\"])], fill=\"green\") # draws rectangle from (40,0) to (100, y_surface) in green\n",
|
114 |
-
"draw.rectangle([(40, line[\"y_surface\"]),\n",
|
115 |
-
" (100, line[\"y_bed\"])], fill=\"white\") # draws rectangle from (40, y_surface) to (100, y_bed) in white\n",
|
116 |
-
"img.show()"
|
117 |
-
]
|
118 |
-
},
|
119 |
-
{
|
120 |
-
"cell_type": "code",
|
121 |
-
"execution_count": null,
|
122 |
-
"metadata": {},
|
123 |
-
"outputs": [],
|
124 |
-
"source": [
|
125 |
-
"# This code draws the segmentation masks for each scope from the csv file and saves them\n",
|
126 |
-
"\n",
|
127 |
-
"# Loop over all the files in the \"secondleg\" directory\n",
|
128 |
-
"for testset in os.listdir(\"secondleg\"):\n",
|
129 |
-
" # Print the name of the current file\n",
|
130 |
-
" print(testset)\n",
|
131 |
-
"\n",
|
132 |
-
" tiff = Image.open(pl.Path(\n",
|
133 |
-
" rf'.\\secondleg\\{testset}\\{testset}.tiff'))\n",
|
134 |
-
"\n",
|
135 |
-
" csv = pd.read_csv(pl.Path(\n",
|
136 |
-
" rf'.\\secondleg\\{testset}\\{testset}.csv'))\n",
|
137 |
-
"\n",
|
138 |
-
" with open(pl.Path(\n",
|
139 |
-
" rf'.\\secondleg\\{testset}\\offset.txt')) as f:\n",
|
140 |
-
" offset = f.read()\n",
|
141 |
-
" if offset == \"\":\n",
|
142 |
-
" offset = 0\n",
|
143 |
-
" else:\n",
|
144 |
-
" offset = int(offset)\n",
|
145 |
-
"\n",
|
146 |
-
" # Make a copy of the image and crop it to remove the unneeded parts\n",
|
147 |
-
" img = tiff.copy()\n",
|
148 |
-
" img = img.crop((0, 430, img.size[0], 1790))\n",
|
149 |
-
"\n",
|
150 |
-
" # Convert the image to float and then to grayscale\n",
|
151 |
-
" img_float = Image.fromarray(np.divide(np.array(img), 2**8-1))\n",
|
152 |
-
" img = img_float.convert(\"L\")\n",
|
153 |
-
"\n",
|
154 |
-
" # Save the cropped and converted image to the specified path\n",
|
155 |
-
" img.save(pl.Path(\n",
|
156 |
-
" rf'.\\secondleg\\{testset}\\cropped_img_{testset}.png'))\n",
|
157 |
-
"\n",
|
158 |
-
" # Add the offset to the specified columns of the csv file and reverse the order\n",
|
159 |
-
" csv = csv[[\"x_surface\", \"y_surface\", \"x_bed\", \"y_bed\"]]+offset\n",
|
160 |
-
" csv = csv[::-1].reset_index(drop=True)\n",
|
161 |
-
"\n",
|
162 |
-
" # Create new dataframes for the top and bottom of the image and concatenate them to the previous dataframe\n",
|
163 |
-
" top = pd.DataFrame(\n",
|
164 |
-
" {\"x_surface\": 0, \"y_surface\": csv.iloc[0][\"y_surface\"], \"x_bed\": 0, \"y_bed\": csv.iloc[0][\"y_bed\"]}, index=[0])\n",
|
165 |
-
" bottom = pd.DataFrame({\"x_surface\": tiff.size[0], \"y_surface\": csv.iloc[-1]\n",
|
166 |
-
" [\"y_surface\"], \"x_bed\": tiff.size[0], \"y_bed\": csv.iloc[-1][\"y_bed\"]}, index=[0])\n",
|
167 |
-
" csv = pd.concat([top, csv, bottom], ignore_index=True)\n",
|
168 |
-
"\n",
|
169 |
-
" # Create a draw object for the image for drawing the polygons\n",
|
170 |
-
" draw = ImageDraw.Draw(img)\n",
|
171 |
-
"\n",
|
172 |
-
" # Loop over the rows of the csv file\n",
|
173 |
-
" for i in range(len(csv)-1):\n",
|
174 |
-
" crow = csv.iloc[i]\n",
|
175 |
-
" nrow = csv.iloc[i+1]\n",
|
176 |
-
"\n",
|
177 |
-
" # Define the coordinates for the sky, bed, and bottom polygons\n",
|
178 |
-
" skycooords = [\n",
|
179 |
-
" (crow[\"x_surface\"], 0),\n",
|
180 |
-
" (nrow[\"x_surface\"], 0),\n",
|
181 |
-
" (nrow[\"x_surface\"], nrow[\"y_surface\"]),\n",
|
182 |
-
" (crow[\"x_surface\"], crow[\"y_surface\"])\n",
|
183 |
-
" ]\n",
|
184 |
-
" bedcoords = [\n",
|
185 |
-
" (crow[\"x_surface\"], crow[\"y_surface\"]),\n",
|
186 |
-
" (nrow[\"x_surface\"], nrow[\"y_surface\"]),\n",
|
187 |
-
" (nrow[\"x_bed\"], nrow[\"y_bed\"]),\n",
|
188 |
-
" (crow[\"x_bed\"], crow[\"y_bed\"])\n",
|
189 |
-
" ]\n",
|
190 |
-
" btmcoords = [\n",
|
191 |
-
" (crow[\"x_bed\"], crow[\"y_bed\"]),\n",
|
192 |
-
" (nrow[\"x_bed\"], nrow[\"y_bed\"]),\n",
|
193 |
-
" (nrow[\"x_bed\"], tiff.size[1]),\n",
|
194 |
-
" (crow[\"x_bed\"], tiff.size[1])\n",
|
195 |
-
" ]\n",
|
196 |
-
"\n",
|
197 |
-
" # Draw the polygons on the image\n",
|
198 |
-
" draw.polygon(skycooords, fill=\"#000000\")\n",
|
199 |
-
" draw.polygon(bedcoords, fill=\"#010101\")\n",
|
200 |
-
" draw.polygon(btmcoords, fill=\"#020202\")\n",
|
201 |
-
"\n",
|
202 |
-
" # Save the image with the drawn polygons to the specified path\n",
|
203 |
-
" img.save(pl.Path(\n",
|
204 |
-
" rf'.\\secondleg\\{testset}\\img_mask_{testset}.png'))"
|
205 |
-
]
|
206 |
-
},
|
207 |
-
{
|
208 |
-
"cell_type": "code",
|
209 |
-
"execution_count": null,
|
210 |
-
"metadata": {},
|
211 |
-
"outputs": [],
|
212 |
-
"source": [
|
213 |
-
"# This code is used to crop the images and masks in the second leg data set into 400x400 images.\n",
|
214 |
-
"\n",
|
215 |
-
"# Loop over all the files in the \"secondleg\" directory\n",
|
216 |
-
"for testset in os.listdir(\"secondleg\"):\n",
|
217 |
-
"\n",
|
218 |
-
" cimg = Image.open(pl.Path(\n",
|
219 |
-
" rf'.\\secondleg\\{testset}\\cropped_img_{testset}.png'))\n",
|
220 |
-
"\n",
|
221 |
-
" mask = Image.open(pl.Path(\n",
|
222 |
-
" rf'.\\secondleg\\{testset}\\img_mask_{testset}.png'))\n",
|
223 |
-
"\n",
|
224 |
-
" # Calculate the sections to crop the image into, with each section being 400 pixels wide and an overlap of 80 pixels\n",
|
225 |
-
" cropsection = window_with_remainder(400, 80, cimg.size[0])\n",
|
226 |
-
"\n",
|
227 |
-
" # Try to create directories for the cropped images and masks\n",
|
228 |
-
" try:\n",
|
229 |
-
" os.mkdir(pl.Path(\n",
|
230 |
-
" rf'.\\secondleg\\{testset}\\cropped_images'))\n",
|
231 |
-
"\n",
|
232 |
-
" os.mkdir(pl.Path(\n",
|
233 |
-
" rf'.\\secondleg\\{testset}\\cropped_masks'))\n",
|
234 |
-
" except:\n",
|
235 |
-
" pass\n",
|
236 |
-
"\n",
|
237 |
-
" for i in cropsection:\n",
|
238 |
-
" # Crop the image to the current section, resize it to 400x400, and save it to the specified path\n",
|
239 |
-
" cimg.crop((i[0], 0, i[1], cimg.size[1])).resize((400, 400)).save(pl.Path(\n",
|
240 |
-
" rf'\\secondleg\\{testset}\\cropped_images\\cimg-{testset}_{i[0]}_{i[1]}.png'))\n"
|
241 |
-
]
|
242 |
-
},
|
243 |
-
{
|
244 |
-
"cell_type": "code",
|
245 |
-
"execution_count": null,
|
246 |
-
"metadata": {},
|
247 |
-
"outputs": [],
|
248 |
-
"source": [
|
249 |
-
"from huggingface_hub import notebook_login\n",
|
250 |
-
"\n",
|
251 |
-
"from datasets import Dataset, DatasetDict, Image\n",
|
252 |
-
"\n",
|
253 |
-
"from glob import glob\n",
|
254 |
-
"\n",
|
255 |
-
"images = glob(\"secondleg/*/cropped_images/*.png\")\n",
|
256 |
-
"\n",
|
257 |
-
"masks = glob(\"secondleg/*/cropped_masks/*.png\")\n",
|
258 |
-
"\n",
|
259 |
-
"# Define a function to create a dataset from image and label paths\n",
|
260 |
-
"def create_dataset(image_paths, label_paths):\n",
|
261 |
-
" # Create a Dataset object from a dictionary of image and label paths\n",
|
262 |
-
" dataset = Dataset.from_dict({\"image\": sorted(image_paths),\n",
|
263 |
-
" \"label\": sorted(label_paths)})\n",
|
264 |
-
" dataset = dataset.cast_column(\"image\", Image())\n",
|
265 |
-
" dataset = dataset.cast_column(\"label\", Image())\n",
|
266 |
-
"\n",
|
267 |
-
" return dataset\n",
|
268 |
-
"\n",
|
269 |
-
"\n",
|
270 |
-
"dataset = create_dataset(images, masks)\n",
|
271 |
-
"\n",
|
272 |
-
"notebook_login()\n"
|
273 |
-
]
|
274 |
-
},
|
275 |
-
{
|
276 |
-
"cell_type": "code",
|
277 |
-
"execution_count": null,
|
278 |
-
"metadata": {},
|
279 |
-
"outputs": [],
|
280 |
-
"source": [
|
281 |
-
"# Call the push_to_hub method on the dataset object, specifying the repository name and setting it to private\n",
|
282 |
-
"dataset.push_to_hub(\"aashraychegu/glacier_scopes\", private=True)\n"
|
283 |
-
]
|
284 |
-
}
|
285 |
-
],
|
286 |
-
"metadata": {
|
287 |
-
"kernelspec": {
|
288 |
-
"display_name": "Python 3",
|
289 |
-
"language": "python",
|
290 |
-
"name": "python3"
|
291 |
-
},
|
292 |
-
"language_info": {
|
293 |
-
"codemirror_mode": {
|
294 |
-
"name": "ipython",
|
295 |
-
"version": 3
|
296 |
-
},
|
297 |
-
"file_extension": ".py",
|
298 |
-
"mimetype": "text/x-python",
|
299 |
-
"name": "python",
|
300 |
-
"nbconvert_exporter": "python",
|
301 |
-
"pygments_lexer": "ipython3",
|
302 |
-
"version": "3.10.7"
|
303 |
-
},
|
304 |
-
"orig_nbformat": 4
|
305 |
-
},
|
306 |
-
"nbformat": 4,
|
307 |
-
"nbformat_minor": 2
|
308 |
-
}
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
pytorch_model.bin
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:645484b81f0a46eb0255c974f81dd8c1b661b295be4f718ceb1314c37a0a8c2b
|
3 |
-
size 93128541
|
|
|
|
|
|
|
|
training_args.bin
DELETED
@@ -1,3 +0,0 @@
|
|
1 |
-
version https://git-lfs.github.com/spec/v1
|
2 |
-
oid sha256:4926270a965f402ff1d9e55f76334c231cc5ddde98450c313822fa802e689cc9
|
3 |
-
size 3963
|
|
|
|
|
|
|
|