File size: 1,343 Bytes
90cd92a
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
#!/bin/bash

# Path to the Python script
PYTHON_SCRIPT="/mnt/user/myang/LLaVA-2/my_code/python/testgpt4.py"

# Main directory containing subdirectories with image files
MAIN_DIRECTORY="/mnt/user/myang/OneDrive_1_9-6-2023/facial_attributes/images/train/"

# Path to save the JSON files
JSON_OUTPUT_DIR="/mnt/user/myang/LLaVA-2/my_code/json/gpt4ansjson"

# Check if the Python script exists
if [ ! -f "$PYTHON_SCRIPT" ]; then
    echo "Error: Python script not found: $PYTHON_SCRIPT"
    exit 1
fi

# Check if the main directory exists
if [ ! -d "$MAIN_DIRECTORY" ]; then
    echo "Error: Main directory not found: $MAIN_DIRECTORY"
    exit 1
fi

# Loop through each subdirectory in the main directory
for SUBDIRECTORY in "$MAIN_DIRECTORY"/*/; do
    # Check if the subdirectory contains image files
    if [ -d "$SUBDIRECTORY" ]; then
        # Run the Python script with the specified arguments
        image_files=$(find "$SUBDIRECTORY" -type f -iname "*.jpg" -o -iname "*.png" | head -n 3)
        for image_file in $image_files; do
            # Process each image file here
            echo "Processing image: $image_file"
            python3 "/mnt/user/myang/LLaVA-2/my_code/python/testgpt4.py" "$image_file"
        done
        # python3 "$PYTHON_SCRIPT" "$SUBDIRECTORY"
        # echo "Processing directory: $SUBDIRECTORY"
    fi
done