BiliSakura commited on
Commit
af71ab9
·
verified ·
1 Parent(s): 1e7a60d

Sync updated code and configs (no weight re-upload)

Browse files
README.md CHANGED
@@ -1,19 +1,3 @@
1
- ---
2
- license: mit
3
- language:
4
- - en
5
- tags:
6
- - remote-sensing
7
- - earth-observation
8
- - vision
9
- - feature-extraction
10
- - dofa
11
- - sentinel-2
12
- - multimodal
13
- library_name: transformers
14
- pipeline_tag: feature-extraction
15
- ---
16
-
17
  # DOFA Transformers Models
18
 
19
  Self-contained HuggingFace model checkpoints for [DOFA](https://arxiv.org/abs/2403.15356).
@@ -31,6 +15,8 @@ Sentinel-2 9-band defaults (`default_wavelengths`, `default_image_mean`, `defaul
31
 
32
  ## Usage
33
 
 
 
34
  ```python
35
  from transformers import pipeline
36
 
@@ -42,9 +28,27 @@ pipe = pipeline(
42
  trust_remote_code=True,
43
  )
44
 
 
45
  features = pipe(image_array, pool=True, return_tensors=True)
46
  ```
47
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
48
  Override Sentinel-2 defaults for other sensors:
49
 
50
  ```python
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
  # DOFA Transformers Models
2
 
3
  Self-contained HuggingFace model checkpoints for [DOFA](https://arxiv.org/abs/2403.15356).
 
15
 
16
  ## Usage
17
 
18
+ Processors default to **`do_resize: false`**. Pass Sentinel-2 stacks at native `(H, W, C)`; the processor rescales values (typically `/255`) without changing spatial size.
19
+
20
  ```python
21
  from transformers import pipeline
22
 
 
28
  trust_remote_code=True,
29
  )
30
 
31
+ # Native-resolution patch, e.g. 512×512×9 bands (uint8 or float)
32
  features = pipe(image_array, pool=True, return_tensors=True)
33
  ```
34
 
35
+ Dense features:
36
+
37
+ ```python
38
+ tokens = pipe(image_array, pool=False, return_tensors=True)
39
+ ```
40
+
41
+ Opt in to 224×224 resize (original pretraining size):
42
+
43
+ ```python
44
+ features = pipe(
45
+ image_array,
46
+ pool=True,
47
+ return_tensors=True,
48
+ image_processor_kwargs={"do_resize": True},
49
+ )
50
+ ```
51
+
52
  Override Sentinel-2 defaults for other sensors:
53
 
54
  ```python
dofa-base-patch16-224/__pycache__/modeling_dofa.cpython-311.pyc ADDED
Binary file (21.1 kB). View file
 
dofa-base-patch16-224/__pycache__/pipeline_dofa.cpython-311.pyc ADDED
Binary file (2.76 kB). View file
 
dofa-base-patch16-224/image_processing_dofa.py CHANGED
@@ -51,7 +51,7 @@ class DOFAImageProcessor(BaseImageProcessor):
51
 
52
  def __init__(
53
  self,
54
- do_resize: bool = True,
55
  size: Optional[dict[str, int]] = None,
56
  resample: PILImageResampling = PILImageResampling.BILINEAR,
57
  do_rescale: bool = True,
 
51
 
52
  def __init__(
53
  self,
54
+ do_resize: bool = False,
55
  size: Optional[dict[str, int]] = None,
56
  resample: PILImageResampling = PILImageResampling.BILINEAR,
57
  do_rescale: bool = True,
dofa-base-patch16-224/preprocessor_config.json CHANGED
@@ -4,7 +4,7 @@
4
  "height": 224,
5
  "width": 224
6
  },
7
- "do_resize": true,
8
  "do_rescale": true,
9
  "do_normalize": true,
10
  "do_convert_rgb": false,
 
4
  "height": 224,
5
  "width": 224
6
  },
7
+ "do_resize": false,
8
  "do_rescale": true,
9
  "do_normalize": true,
10
  "do_convert_rgb": false,
dofa-large-patch16-224/__pycache__/pipeline_dofa.cpython-311.pyc ADDED
Binary file (2.76 kB). View file
 
dofa-large-patch16-224/image_processing_dofa.py CHANGED
@@ -51,7 +51,7 @@ class DOFAImageProcessor(BaseImageProcessor):
51
 
52
  def __init__(
53
  self,
54
- do_resize: bool = True,
55
  size: Optional[dict[str, int]] = None,
56
  resample: PILImageResampling = PILImageResampling.BILINEAR,
57
  do_rescale: bool = True,
 
51
 
52
  def __init__(
53
  self,
54
+ do_resize: bool = False,
55
  size: Optional[dict[str, int]] = None,
56
  resample: PILImageResampling = PILImageResampling.BILINEAR,
57
  do_rescale: bool = True,
dofa-large-patch16-224/preprocessor_config.json CHANGED
@@ -4,7 +4,7 @@
4
  "height": 224,
5
  "width": 224
6
  },
7
- "do_resize": true,
8
  "do_rescale": true,
9
  "do_normalize": true,
10
  "do_convert_rgb": false,
 
4
  "height": 224,
5
  "width": 224
6
  },
7
+ "do_resize": false,
8
  "do_rescale": true,
9
  "do_normalize": true,
10
  "do_convert_rgb": false,