File size: 3,572 Bytes
f36bbc5
 
 
 
 
 
 
 
 
 
 
 
 
0af0696
 
0eabbc1
0af0696
 
 
 
 
 
 
 
 
 
 
 
 
 
74a523c
0af0696
 
74a523c
 
 
 
 
 
 
 
 
 
d97825c
74a523c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
19ee8c3
74a523c
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
47
48
49
50
51
52
53
54
55
56
57
58
59
60
61
62
63
64
65
66
67
68
69
70
71
72
73
74
75
76
77
78
79
80
81
82
83
84
85
86
87
88
89
90
91
92
93
94
95
96
97
98
99
100
101
102
103
104
105
106
107
108
109
110
111
112
113
114
115
116
117
118
119
120
121
---
title: SpecDETR Gradio App
emoji: πŸš€
colorFrom: indigo
colorTo: blue
sdk: gradio
sdk_version: "3.50.2"
app_file: app.py
pinned: false
---

Check out the configuration reference at https://huggingface.co./docs/hub/spaces-config-reference

# SpecDETR Hugging Face Space

This repository contains a Gradio demo for SpecDETR, supporting both image and video detection.

## Usage
- Upload your model config (.py) and checkpoint (.pth) files to the interface.
- Test detection on images or videos using the Gradio UI.

## Files
- `app.py`: Gradio app entry point.
- `requirements.txt`: Python dependencies for Hugging Face Spaces.
- `download_spod.py`: (Optional) Script for dataset download and config update.

## Deployment
1. Push this repo to your Hugging Face Space.
2. The Space will auto-build and launch the Gradio demo.

<<<<<<< HEAD
## Note
- If you need to add default configs or checkpoints, place them in the repo and update `app.py` accordingly.
=======
The code is built upon mmdetection 3.0.0 and runs on the Ubuntu system.

1. Create a new conda environment and activate the environment. Requires Python>=3.7.

2. Install Pytorch. Requires torch>=1.8.

3. Install mmengine and mmcv.
    ```
    pip install mmengine==0.7.3
    pip install mmcv>=2.0.0
    ```
   
4. Clone this repository:
    ```
    SpecDETR_ROOT=/path/to/clone/SpecDETR
    git clone https://github.com/ZhaoxuLi123/SpecDETR $SpecDETR_ROOT
    ```
   
5. Compile and install mmdet. If mmdet>=3.0.0 is already installed in the environment, skip this step.
    ```
    cd SpecDETR_ROOT
    pip install -v -e .
    ```
   
## SPOD Dataset Preparation

1. Download SPOD_30b_8c.zip from [Baidu Netdisk](https://pan.baidu.com/s/1vw23KWPSus2Yuj-CA1URnw?pwd=1234) (code: 1234) or [Google Drive](https://drive.google.com/file/d/1wfoLkfZOxxEtuDyDSWCnAq-N8HZVKdQ1/view?usp=drive_link).

2. Unzip SPOD_30b_8c.zip to the specified path.
    ```
    SPOD_ROOT=/path/to/unzip/SPOD_dataset
    unzip -d SPOD_ROOT SPOD_30b_8c.zip
    ```
   
3. Update the dataset configuration file ./configs/_base_/datasets/hsi_detection.py
    ```
    Line3 data_root = 'SPOD_ROOT/SPOD_30b_8c/'
    ```
   
## Benchmark Evaluation and Training

### Pre-trained Weights Preparation

1. Download the pre-trained weights file SpecDETR_100e.pth from [Baidu Netdisk](https://pan.baidu.com/s/12-33-sCQWcMYUy5QU7rVNQ?pwd=1234) (code: 1234) or [Google Drive](https://drive.google.com/file/d/1h6_MzTb_jQ-7I09x2qfg4vci4hA50hhY/view?usp=drive_link).

2. Place the file SpecDETR_100e.pth under ./work_dirs/SpecDETR/

### Evaluation

1. Obtain detection results and evaluate AP.
    ```
    python test.py
    ```
   
2. Evaluate inference speed FPS.
    ```
    python train.py
    ```
   
3. Evaluate flops.
    ```
    python benchmark.py
    ```
   
4. Retrain the network from scratch.
    ```
    python train.py
    ```
  Note: Although we have fixed all random seeds, there may still be slight differences in AP performance after retraining from scratch each time. This difference originates from the underlying mechanism of CUDA.

## Citation

If the work or the code is helpful, please cite the paper:
```
@article{li2024specdetr,
  title={SpecDETR: A Transformer-based Hyperspectral Point Object Detection Network},
  author={Li, Zhaoxu and An, Wei and Guo, Gaowei and Wang, Longguang and Wang, Yingqian and Lin, Zaiping},
  journal={arXiv preprint arXiv:2405.10148},
  year={2024}
}
```

## Contact

For further questions or details, please directly reach out to [email protected].
>>>>>>> dc3c711 (Update README.md)