Datasets:
Update unzipping.sh developer_README.md
Browse files- developer_README.md +24 -4
- unzipping.sh +101 -0
- zipping.sh +1 -1
developer_README.md
CHANGED
|
@@ -10,12 +10,32 @@ First, clone the repository from Hugging Face to your local machine:
|
|
| 10 |
# Make sure git-lfs is installed (https://git-lfs.com)
|
| 11 |
git lfs install
|
| 12 |
git clone https://huggingface.co/datasets/OtoroLin/HyperForensics-plus-plus
|
|
|
|
| 13 |
```
|
| 14 |
## 2. Extract the Dataset
|
| 15 |
-
|
|
|
|
| 16 |
```bash
|
| 17 |
-
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 18 |
```
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 19 |
## 3. Modify or Generate Data
|
| 20 |
Make changes or generate new data in the extracted directory. Ensure the data follows the required structure:
|
| 21 |
```
|
|
@@ -34,7 +54,7 @@ HyperForensics-plus-plus/
|
|
| 34 |
|-data/
|
| 35 |
```
|
| 36 |
## 4. Zip the Directory
|
| 37 |
-
After modifying or generating data, zip the directory into
|
| 38 |
|
| 39 |
You can utilize the provided `zipping.sh` script. First, modify the `ROOT_DIR` variable to the `local_data` path
|
| 40 |
```bash
|
|
@@ -42,7 +62,7 @@ You can utilize the provided `zipping.sh` script. First, modify the `ROOT_DIR` v
|
|
| 42 |
# Defined the root directory of the whole dataset
|
| 43 |
ROOT_DIR="/root/to/local_data"
|
| 44 |
```
|
| 45 |
-
### 4.1 Compressing specify
|
| 46 |
```bash
|
| 47 |
./zipping.sh --method <method name> --config <config name>
|
| 48 |
```
|
|
|
|
| 10 |
# Make sure git-lfs is installed (https://git-lfs.com)
|
| 11 |
git lfs install
|
| 12 |
git clone https://huggingface.co/datasets/OtoroLin/HyperForensics-plus-plus
|
| 13 |
+
cd ./HyperForensics-plus-plus
|
| 14 |
```
|
| 15 |
## 2. Extract the Dataset
|
| 16 |
+
**The `unzipping.sh` has not been done**
|
| 17 |
+
Unzip the data.tar.gz file into a separate local directory. You can utilize the provided `zipping.sh` script. First, modify the `ROOT_DIR` variable to the `local_data` path
|
| 18 |
```bash
|
| 19 |
+
# In zipping.sh
|
| 20 |
+
# Defined the root directory of the whole dataset
|
| 21 |
+
ROOT_DIR="/root/to/local_data"
|
| 22 |
+
```
|
| 23 |
+
### 2.1 Decompressing the specify method and configuration:
|
| 24 |
+
```bash
|
| 25 |
+
./unzipping.sh --method <method name> --config <config name>
|
| 26 |
```
|
| 27 |
+
Replace `<method name>` with the forgery method and `<config name>` with the configuration index. This will automatically decompressed `.tar.gz` file and put it under hirarchy of the local dataset directory.
|
| 28 |
+
For instance, if I want to decompress the images under `ADMM-ADAM` forgery method, `config0` configuration:
|
| 29 |
+
```bash
|
| 30 |
+
./unzipping.sh --method ADMM-ADAM --config 0
|
| 31 |
+
```
|
| 32 |
+
This will decompress `HyperForensics-plus-plus/data/ADMM-ADAM/config0/config0.tar.gz` to `/path/to/local/ADMM-ADAM/config0/*`.
|
| 33 |
+
### 2.2 Decompress the entire hirarchy
|
| 34 |
+
```bash
|
| 35 |
+
./unzipping.sh --all
|
| 36 |
+
```
|
| 37 |
+
This will recursively decompress all `tar.gz` file in the `HyperForensics-plus-plus/data` and automatically put the decompressed files under hirarchy of the local dataset directory.
|
| 38 |
+
|
| 39 |
## 3. Modify or Generate Data
|
| 40 |
Make changes or generate new data in the extracted directory. Ensure the data follows the required structure:
|
| 41 |
```
|
|
|
|
| 54 |
|-data/
|
| 55 |
```
|
| 56 |
## 4. Zip the Directory
|
| 57 |
+
After modifying or generating data, zip the directory into `.tar.gz` files and place it in the repository.
|
| 58 |
|
| 59 |
You can utilize the provided `zipping.sh` script. First, modify the `ROOT_DIR` variable to the `local_data` path
|
| 60 |
```bash
|
|
|
|
| 62 |
# Defined the root directory of the whole dataset
|
| 63 |
ROOT_DIR="/root/to/local_data"
|
| 64 |
```
|
| 65 |
+
### 4.1 Compressing the specify method and configuration:
|
| 66 |
```bash
|
| 67 |
./zipping.sh --method <method name> --config <config name>
|
| 68 |
```
|
unzipping.sh
CHANGED
|
@@ -0,0 +1,101 @@
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
| 1 |
+
#!/bin/bash
|
| 2 |
+
|
| 3 |
+
# Defined the root directory of the whole dataset
|
| 4 |
+
ROOT_DIR="/ssd2/TzuYu/data_test"
|
| 5 |
+
|
| 6 |
+
# Function to display usage
|
| 7 |
+
usage() {
|
| 8 |
+
echo "Usage: $0 [--method METHOD --config CONFIG] | [--all]"
|
| 9 |
+
exit 1
|
| 10 |
+
}
|
| 11 |
+
# Function to unzip a single directory
|
| 12 |
+
unzip_config() {
|
| 13 |
+
local method=$1
|
| 14 |
+
local config=$2
|
| 15 |
+
local output_path="$ROOT_DIR/$method/$config"
|
| 16 |
+
local zipped_file="./data/$method/$config/$config.tar.gz"
|
| 17 |
+
|
| 18 |
+
# Ensure the output directory exists
|
| 19 |
+
mkdir -p "$output_path"
|
| 20 |
+
|
| 21 |
+
# Create the tar.gz file
|
| 22 |
+
echo "Decompressing $zipped_file to $output_path"
|
| 23 |
+
tar -xvzf "$zipped_file" -C "$output_path"
|
| 24 |
+
if [[ $? -ne 0 ]]; then
|
| 25 |
+
echo "Error: Failed to decompress $zipped_file"
|
| 26 |
+
exit 1
|
| 27 |
+
fi
|
| 28 |
+
}
|
| 29 |
+
|
| 30 |
+
# Parse arguments
|
| 31 |
+
while [[ "$#" -gt 0 ]]; do
|
| 32 |
+
case $1 in
|
| 33 |
+
--help) usage ;;
|
| 34 |
+
--h) usage ;;
|
| 35 |
+
--all) ALL="true" ;;
|
| 36 |
+
--method) METHOD="$2"; shift ;;
|
| 37 |
+
--config) CONFIG="$2"; shift ;;
|
| 38 |
+
*) echo "Unknown parameter: $1"; usage ;;
|
| 39 |
+
esac
|
| 40 |
+
shift
|
| 41 |
+
done
|
| 42 |
+
|
| 43 |
+
# unzipping all folders
|
| 44 |
+
if [[ "$ALL" == "true" ]]; then
|
| 45 |
+
# Iterate through all methods and configs
|
| 46 |
+
for method_dir in "./data/*"; do
|
| 47 |
+
if [[ -d "$method_dir" && "$(basename "$method_dir")" != "Origin" ]]; then
|
| 48 |
+
method=$(basename "$method_dir")
|
| 49 |
+
for config_dir in "$method_dir"/config*; do
|
| 50 |
+
if [[ -d "$config_dir" ]]; then
|
| 51 |
+
config=$(basename "$config_dir")
|
| 52 |
+
unzip_config "$method" "$config"
|
| 53 |
+
fi
|
| 54 |
+
done
|
| 55 |
+
fi
|
| 56 |
+
done
|
| 57 |
+
|
| 58 |
+
if [ -e "./data/Origin/Origin.tar.gz" ]; then
|
| 59 |
+
# Ensure the output directory exists
|
| 60 |
+
mkdir -p "$ROOT_DIR/Origin"
|
| 61 |
+
|
| 62 |
+
# decompress tar.gz file
|
| 63 |
+
echo "Decompressing ./data/Origin/Origin.tar.gz to $ROOT_DIR/Origin"
|
| 64 |
+
tar -xvzf "./data/Origin/Origin.tar.gz" -C "$ROOT_DIR"/Origin/
|
| 65 |
+
if [[ $? -ne 0 ]]; then
|
| 66 |
+
echo "Error: Failed to decompress ./data/Origin/Origin.tar.gz"
|
| 67 |
+
exit 1
|
| 68 |
+
fi
|
| 69 |
+
fi
|
| 70 |
+
echo "All configurations have been zipped successfully."
|
| 71 |
+
exit 0
|
| 72 |
+
fi
|
| 73 |
+
|
| 74 |
+
|
| 75 |
+
# Validate arguments
|
| 76 |
+
if [[ ! -n "$METHOD" || ! -n "$CONFIG" ]]; then
|
| 77 |
+
echo "Error: Both --method and --config or --all must be specified."
|
| 78 |
+
usage
|
| 79 |
+
fi
|
| 80 |
+
|
| 81 |
+
OUTPUT_PATH="$ROOT_DIR/$METHOD/config$CONFIG"
|
| 82 |
+
|
| 83 |
+
# Extract method and config index from the directory path
|
| 84 |
+
METHOD=$(basename "$(dirname "$OUTPUT_PATH")")
|
| 85 |
+
CONFIG=$(basename "$OUTPUT_PATH")
|
| 86 |
+
|
| 87 |
+
INPUT_TAR="./data/$METHOD/$CONFIG/$CONFIG.tar.gz"
|
| 88 |
+
|
| 89 |
+
# Ensure the output directory exists
|
| 90 |
+
mkdir -p "$OUTPUT_PATH"
|
| 91 |
+
|
| 92 |
+
# Create the tar.gz file
|
| 93 |
+
echo "Decompressing: $INPUT_TAR to $OUTPUT_PATH"
|
| 94 |
+
tar -xvzf "$INPUT_TAR" -C "$OUTPUT_PATH"
|
| 95 |
+
if [[ $? -ne 0 ]]; then
|
| 96 |
+
echo "Error: Failed to create tar.gz file."
|
| 97 |
+
exit 1
|
| 98 |
+
fi
|
| 99 |
+
|
| 100 |
+
# Confirm completion
|
| 101 |
+
echo "Decompressing $INPUT_TAR suclsit essfully to $OUTPUT_PATH"
|
zipping.sh
CHANGED
|
@@ -5,7 +5,7 @@ ROOT_DIR="/ssd2/TzuYu/data"
|
|
| 5 |
|
| 6 |
# Function to display usage
|
| 7 |
usage() {
|
| 8 |
-
echo "Usage: $0 [--method METHOD --config CONFIG] | [--dir-path DIR_PATH]"
|
| 9 |
exit 1
|
| 10 |
}
|
| 11 |
# Function to zip a single directory
|
|
|
|
| 5 |
|
| 6 |
# Function to display usage
|
| 7 |
usage() {
|
| 8 |
+
echo "Usage: $0 [--method METHOD --config CONFIG] | [--dir-path DIR_PATH] | [--all]"
|
| 9 |
exit 1
|
| 10 |
}
|
| 11 |
# Function to zip a single directory
|