drdata commited on
Commit
3402506
Β·
verified Β·
1 Parent(s): 52e9197

Upload folder using huggingface_hub

Browse files
DIRECTORY_ACCESS_GUIDE.md ADDED
@@ -0,0 +1,96 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # BytePlus Image Generation Studio - Directory Access Guide
2
+
3
+ ## βœ… Problem Resolved!
4
+
5
+ The `view_session/`, `Generated/`, and `static/` folders are now accessible. Here's what was done:
6
+
7
+ ### πŸ”§ What Was Fixed
8
+
9
+ 1. **Permission Issues**: The `.cache` directory had restrictive permissions (700) that prevented access
10
+ 2. **Missing Directories**: The folders weren't created until the app actually generates images
11
+ 3. **Path Confusion**: The folders exist inside the hidden `.cache` directory
12
+
13
+ ### πŸ“ Directory Structure
14
+
15
+ ```
16
+ /Users/data/SGS-1/
17
+ β”œβ”€β”€ .cache/ # Hidden cache (downloaded Hugging Face space)
18
+ β”‚ β”œβ”€β”€ Generated/ # Original generated images folder
19
+ β”‚ β”œβ”€β”€ static/ # Original static files folder
20
+ β”‚ β”œβ”€β”€ view_session/ # Original session viewer folder
21
+ β”‚ └── app.py # Downloaded BytePlus app
22
+ β”œβ”€β”€ Generated -> .cache/Generated # Symbolic link for easy access
23
+ β”œβ”€β”€ static -> .cache/static # Symbolic link for easy access
24
+ β”œβ”€β”€ view_session -> .cache/view_session # Symbolic link for easy access
25
+ β”œβ”€β”€ run_app.py # Helper script to run the app
26
+ └── check_directories.py # Script to check directory status
27
+ ```
28
+
29
+ ### πŸš€ How to Use
30
+
31
+ #### Option 1: Use the Helper Script (Recommended)
32
+ ```bash
33
+ # Run the app with automatic setup
34
+ python run_app.py
35
+
36
+ # Or just setup directories without running
37
+ python run_app.py --setup-only
38
+ ```
39
+
40
+ #### Option 2: Manual Commands
41
+ ```bash
42
+ # Check directory status
43
+ python check_directories.py
44
+
45
+ # Run the downloaded app directly
46
+ cd .cache && python app.py
47
+ ```
48
+
49
+ ### πŸ“‚ Directory Functions
50
+
51
+ - **`Generated/`**: Stores generated images organized by session (e.g., `session_20240924_143052/`)
52
+ - **`static/`**: Contains static files served by the web interface (ZIP downloads, etc.)
53
+ - **`view_session/`**: Used by the web interface for session viewing functionality
54
+
55
+ ### 🌐 Web Interface URLs
56
+
57
+ When the app is running, you can access:
58
+ - Main interface: `http://localhost:7860` (or the port shown in terminal)
59
+ - Session viewer: `http://localhost:7860/view_session/{timestamp}`
60
+ - Static files: `http://localhost:7860/static/filename.zip`
61
+
62
+ ### πŸ› οΈ Troubleshooting
63
+
64
+ If you still can't access the directories:
65
+
66
+ 1. **Check permissions**:
67
+ ```bash
68
+ ls -la .cache
69
+ # Should show: drwxr-xr-x (755 permissions)
70
+ ```
71
+
72
+ 2. **Recreate symbolic links**:
73
+ ```bash
74
+ python run_app.py --setup-only
75
+ ```
76
+
77
+ 3. **Check directory status**:
78
+ ```bash
79
+ python check_directories.py
80
+ ```
81
+
82
+ ### πŸ“ Notes
83
+
84
+ - The directories will be empty until you actually generate images using the app
85
+ - Session folders are created with timestamps like `session_20240924_143052`
86
+ - ZIP files for downloads are automatically created in the `static/` folder
87
+ - The `view_session/` functionality allows viewing generated images via web browser
88
+
89
+ ### πŸ”— Related Files
90
+
91
+ - `app.py` - Original loader script
92
+ - `.cache/app.py` - Downloaded BytePlus Image Generation Studio
93
+ - `run_app.py` - Helper script for running the app
94
+ - `check_directories.py` - Directory status checker
95
+
96
+ The directories are now fully accessible and the app is ready to use! πŸŽ‰
app_security.log CHANGED
@@ -4,3 +4,9 @@
4
  2025-09-18 16:09:01,000 - httpx - INFO - HTTP Request: GET http://127.0.0.1:7860/gradio_api/startup-events "HTTP/1.1 200 OK"
5
  2025-09-18 16:09:01,058 - httpx - INFO - HTTP Request: HEAD http://127.0.0.1:7860/ "HTTP/1.1 200 OK"
6
  2025-09-18 16:09:01,555 - httpx - INFO - HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
 
 
 
 
 
 
 
4
  2025-09-18 16:09:01,000 - httpx - INFO - HTTP Request: GET http://127.0.0.1:7860/gradio_api/startup-events "HTTP/1.1 200 OK"
5
  2025-09-18 16:09:01,058 - httpx - INFO - HTTP Request: HEAD http://127.0.0.1:7860/ "HTTP/1.1 200 OK"
6
  2025-09-18 16:09:01,555 - httpx - INFO - HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
7
+ 2025-09-24 14:48:31,960 - httpx - INFO - HTTP Request: GET http://127.0.0.1:7860/gradio_api/startup-events "HTTP/1.1 200 OK"
8
+ 2025-09-24 14:48:32,033 - httpx - INFO - HTTP Request: HEAD http://127.0.0.1:7860/ "HTTP/1.1 200 OK"
9
+ 2025-09-24 14:48:32,577 - httpx - INFO - HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
10
+ 2025-09-24 14:58:07,144 - httpx - INFO - HTTP Request: GET http://127.0.0.1:7860/gradio_api/startup-events "HTTP/1.1 200 OK"
11
+ 2025-09-24 14:58:07,220 - httpx - INFO - HTTP Request: HEAD http://127.0.0.1:7860/ "HTTP/1.1 200 OK"
12
+ 2025-09-24 14:58:07,761 - httpx - INFO - HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
check_directories.py ADDED
@@ -0,0 +1,73 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Directory status checker for BytePlus Image Generation Studio
4
+ """
5
+
6
+ import os
7
+ from pathlib import Path
8
+
9
+ def check_directory_status():
10
+ """Check the status of all required directories"""
11
+ print("πŸ” Directory Status Check")
12
+ print("=" * 40)
13
+
14
+ # Check main directories
15
+ directories = {
16
+ "Cache Directory": ".cache",
17
+ "Generated Images": "Generated",
18
+ "Static Files": "static",
19
+ "Session Viewer": "view_session"
20
+ }
21
+
22
+ for name, path in directories.items():
23
+ path_obj = Path(path)
24
+
25
+ print(f"\nπŸ“ {name}:")
26
+ print(f" Path: {path}")
27
+
28
+ if path_obj.exists():
29
+ if path_obj.is_symlink():
30
+ target = path_obj.readlink()
31
+ print(f" Status: βœ… Symbolic link -> {target}")
32
+ else:
33
+ print(f" Status: βœ… Directory exists")
34
+
35
+ # Check permissions
36
+ try:
37
+ items = list(path_obj.iterdir())
38
+ print(f" Contents: {len(items)} items")
39
+ if items:
40
+ print(f" Sample: {[item.name for item in items[:3]]}")
41
+ else:
42
+ print(f" Contents: Empty")
43
+ except PermissionError:
44
+ print(f" Status: ❌ Permission denied")
45
+ except Exception as e:
46
+ print(f" Status: ⚠️ Error accessing: {e}")
47
+ else:
48
+ print(f" Status: ❌ Does not exist")
49
+
50
+ # Check cache directory permissions
51
+ print(f"\nπŸ”’ Permissions Check:")
52
+ cache_path = Path(".cache")
53
+ if cache_path.exists():
54
+ stat_info = cache_path.stat()
55
+ permissions = oct(stat_info.st_mode)[-3:]
56
+ print(f" Cache directory permissions: {permissions}")
57
+ if permissions == "755":
58
+ print(" βœ… Permissions are correct")
59
+ else:
60
+ print(" ⚠️ Permissions may need adjustment")
61
+
62
+ # Check if app is ready to run
63
+ print(f"\nπŸš€ App Status:")
64
+ app_file = Path(".cache/app.py")
65
+ if app_file.exists():
66
+ print(" βœ… App is downloaded and ready to run")
67
+ print(" πŸ’‘ Use: python run_app.py")
68
+ else:
69
+ print(" ❌ App not downloaded yet")
70
+ print(" πŸ’‘ Use: python app.py (to download first)")
71
+
72
+ if __name__ == "__main__":
73
+ check_directory_status()
fix_permissions.sh ADDED
@@ -0,0 +1,66 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/bin/bash
2
+ # Targeted permission fix for specific folders only
3
+ # This script affects ONLY the directories you're interested in
4
+
5
+ echo "🎯 Fixing permissions for specific directories only..."
6
+ echo "Target directories: Generated, static, view_session"
7
+ echo "=================================================="
8
+
9
+ # Check if directories exist first
10
+ check_directory() {
11
+ if [ -d "$1" ]; then
12
+ current_perms=$(stat -f "%Mp%Lp" "$1" 2>/dev/null || stat -c "%a" "$1" 2>/dev/null)
13
+ echo "πŸ“ $1 - Current permissions: $current_perms"
14
+ return 0
15
+ else
16
+ echo "⚠️ $1 - Does not exist"
17
+ return 1
18
+ fi
19
+ }
20
+
21
+ fix_directory_permissions() {
22
+ if [ -d "$1" ]; then
23
+ echo "πŸ”§ Fixing permissions for: $1"
24
+
25
+ # Fix directory permissions (755 = rwxr-xr-x)
26
+ chmod 755 "$1"
27
+
28
+ # Fix permissions for all contents recursively
29
+ # Directories: 755, Files: 644
30
+ find "$1" -type d -exec chmod 755 {} \; 2>/dev/null
31
+ find "$1" -type f -exec chmod 644 {} \; 2>/dev/null
32
+
33
+ echo "βœ… Fixed: $1"
34
+ else
35
+ echo "❌ Cannot fix: $1 (does not exist)"
36
+ fi
37
+ }
38
+
39
+ echo "Current status:"
40
+ check_directory ".cache/Generated"
41
+ check_directory ".cache/static"
42
+ check_directory ".cache/view_session"
43
+
44
+ echo ""
45
+ echo "Do you want to fix permissions for these directories? (y/N)"
46
+ read -r response
47
+
48
+ if [[ "$response" =~ ^[Yy]$ ]]; then
49
+ echo ""
50
+ echo "Applying permission fixes..."
51
+
52
+ # Fix permissions for the actual directories in .cache
53
+ fix_directory_permissions ".cache/Generated"
54
+ fix_directory_permissions ".cache/static"
55
+ fix_directory_permissions ".cache/view_session"
56
+
57
+ echo ""
58
+ echo "βœ… Permission fix complete!"
59
+ echo ""
60
+ echo "Final status:"
61
+ check_directory ".cache/Generated"
62
+ check_directory ".cache/static"
63
+ check_directory ".cache/view_session"
64
+ else
65
+ echo "Operation cancelled."
66
+ fi
fix_specific_permissions.py ADDED
@@ -0,0 +1,105 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Targeted permission fix for specific directories only
4
+ This script fixes permissions ONLY for the directories you're interested in
5
+ """
6
+
7
+ import os
8
+ import stat
9
+ from pathlib import Path
10
+
11
+ def fix_specific_permissions():
12
+ """Fix permissions only for the target directories and their contents"""
13
+
14
+ # Target directories (both actual and symlink paths)
15
+ target_dirs = [
16
+ ".cache/Generated",
17
+ ".cache/static",
18
+ ".cache/view_session",
19
+ "Generated", # symlink
20
+ "static", # symlink
21
+ "view_session" # symlink
22
+ ]
23
+
24
+ print("πŸ”§ Fixing permissions for specific directories only...")
25
+ print("=" * 50)
26
+
27
+ for dir_path in target_dirs:
28
+ path_obj = Path(dir_path)
29
+
30
+ if not path_obj.exists():
31
+ print(f"⚠️ {dir_path} - Does not exist, skipping")
32
+ continue
33
+
34
+ try:
35
+ # Fix the directory itself
36
+ if path_obj.is_dir() and not path_obj.is_symlink():
37
+ current_perms = oct(path_obj.stat().st_mode)[-3:]
38
+ path_obj.chmod(0o755) # rwxr-xr-x
39
+ print(f"βœ… {dir_path} - Fixed directory permissions ({current_perms} β†’ 755)")
40
+
41
+ # Fix all contents recursively
42
+ fix_contents_permissions(path_obj)
43
+
44
+ elif path_obj.is_symlink():
45
+ print(f"πŸ”— {dir_path} - Symbolic link (no permission fix needed)")
46
+ else:
47
+ print(f"⚠️ {dir_path} - Not a directory, skipping")
48
+
49
+ except Exception as e:
50
+ print(f"❌ {dir_path} - Error: {e}")
51
+
52
+ def fix_contents_permissions(directory_path):
53
+ """Recursively fix permissions for directory contents"""
54
+ try:
55
+ for item in directory_path.rglob("*"):
56
+ try:
57
+ if item.is_dir():
58
+ item.chmod(0o755) # Directories: rwxr-xr-x
59
+ elif item.is_file():
60
+ item.chmod(0o644) # Files: rw-r--r--
61
+ except Exception as e:
62
+ print(f" ⚠️ {item} - Could not fix: {e}")
63
+
64
+ except Exception as e:
65
+ print(f" ❌ Error scanning {directory_path}: {e}")
66
+
67
+ def check_permissions():
68
+ """Check current permissions of target directories"""
69
+ print("\nπŸ” Current Permissions Check:")
70
+ print("-" * 30)
71
+
72
+ target_dirs = [
73
+ ".cache/Generated",
74
+ ".cache/static",
75
+ ".cache/view_session"
76
+ ]
77
+
78
+ for dir_path in target_dirs:
79
+ path_obj = Path(dir_path)
80
+ if path_obj.exists():
81
+ perms = oct(path_obj.stat().st_mode)[-3:]
82
+ access_status = "βœ… Accessible" if perms in ["755", "775"] else "❌ Restricted"
83
+ print(f"{dir_path:20} - {perms} ({access_status})")
84
+ else:
85
+ print(f"{dir_path:20} - Does not exist")
86
+
87
+ if __name__ == "__main__":
88
+ print("🎯 Targeted Permission Fix for Specific Directories")
89
+ print("This script ONLY affects view_session, Generated, and static folders")
90
+ print("=" * 70)
91
+
92
+ # Check current state
93
+ check_permissions()
94
+
95
+ # Ask for confirmation
96
+ print("\n" + "=" * 50)
97
+ response = input("Fix permissions for these directories? (y/N): ").strip().lower()
98
+
99
+ if response in ['y', 'yes']:
100
+ fix_specific_permissions()
101
+ print("\n" + "=" * 50)
102
+ print("βœ… Permission fix complete!")
103
+ check_permissions()
104
+ else:
105
+ print("Operation cancelled.")
manual_permission_commands.txt ADDED
@@ -0,0 +1,27 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Manual Commands for Targeted Permission Fix
2
+ # Copy and paste these commands to fix ONLY the specific directories
3
+
4
+ # 1. Check current permissions
5
+ echo "Current permissions:"
6
+ ls -ld .cache/Generated .cache/static .cache/view_session 2>/dev/null
7
+
8
+ # 2. Fix permissions for the three directories only
9
+ chmod 755 .cache/Generated 2>/dev/null
10
+ chmod 755 .cache/static 2>/dev/null
11
+ chmod 755 .cache/view_session 2>/dev/null
12
+
13
+ # 3. Fix permissions for contents inside these directories
14
+ find .cache/Generated -type d -exec chmod 755 {} \; 2>/dev/null
15
+ find .cache/Generated -type f -exec chmod 644 {} \; 2>/dev/null
16
+
17
+ find .cache/static -type d -exec chmod 755 {} \; 2>/dev/null
18
+ find .cache/static -type f -exec chmod 644 {} \; 2>/dev/null
19
+
20
+ find .cache/view_session -type d -exec chmod 755 {} \; 2>/dev/null
21
+ find .cache/view_session -type f -exec chmod 644 {} \; 2>/dev/null
22
+
23
+ # 4. Verify the changes
24
+ echo "Updated permissions:"
25
+ ls -ld .cache/Generated .cache/static .cache/view_session 2>/dev/null
26
+
27
+ echo "βœ… Permission fix complete for specific directories only"
run_app.py ADDED
@@ -0,0 +1,98 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ #!/usr/bin/env python3
2
+ """
3
+ Helper script to run the BytePlus Image Generation Studio
4
+ This ensures the proper directories are created and accessible
5
+ """
6
+
7
+ import os
8
+ import sys
9
+ import subprocess
10
+ from pathlib import Path
11
+
12
+ def setup_directories():
13
+ """Ensure all required directories exist and are accessible"""
14
+ cache_dir = Path(".cache")
15
+
16
+ # Required directories
17
+ directories = [
18
+ cache_dir / "Generated",
19
+ cache_dir / "static",
20
+ cache_dir / "view_session"
21
+ ]
22
+
23
+ print("Setting up directories...")
24
+ for directory in directories:
25
+ directory.mkdir(parents=True, exist_ok=True)
26
+ print(f"βœ… Created/verified: {directory}")
27
+
28
+ # Fix cache directory permissions if needed
29
+ try:
30
+ cache_dir.chmod(0o755)
31
+ print("βœ… Fixed cache directory permissions")
32
+ except Exception as e:
33
+ print(f"⚠️ Could not fix permissions: {e}")
34
+
35
+ # Create symbolic links for easy access
36
+ main_dir = Path(".")
37
+ links = [
38
+ ("Generated", cache_dir / "Generated"),
39
+ ("static", cache_dir / "static"),
40
+ ("view_session", cache_dir / "view_session")
41
+ ]
42
+
43
+ for link_name, target in links:
44
+ link_path = main_dir / link_name
45
+ if link_path.exists() or link_path.is_symlink():
46
+ if link_path.is_symlink():
47
+ link_path.unlink()
48
+ elif link_path.is_dir():
49
+ # If it's a directory, rename it to backup
50
+ backup_name = f"{link_name}_backup"
51
+ link_path.rename(main_dir / backup_name)
52
+ print(f"πŸ“ Backed up existing directory to {backup_name}")
53
+
54
+ try:
55
+ link_path.symlink_to(target)
56
+ print(f"πŸ”— Created symlink: {link_name} -> {target}")
57
+ except Exception as e:
58
+ print(f"⚠️ Could not create symlink {link_name}: {e}")
59
+
60
+ def run_app():
61
+ """Run the downloaded application"""
62
+ cache_dir = Path(".cache")
63
+ app_file = cache_dir / "app.py"
64
+
65
+ if not app_file.exists():
66
+ print("❌ App file not found. Please run the main app.py first to download the space.")
67
+ return False
68
+
69
+ print(f"πŸš€ Starting application from {app_file}")
70
+ print("πŸ“ Generated images will be stored in: ./Generated/")
71
+ print("🌐 Static files will be served from: ./static/")
72
+ print("πŸ‘οΈ Session viewer will be available at: /view_session/")
73
+ print("-" * 50)
74
+
75
+ # Change to cache directory and run the app
76
+ os.chdir(cache_dir)
77
+ try:
78
+ subprocess.run([sys.executable, "app.py"], check=True)
79
+ except KeyboardInterrupt:
80
+ print("\n⏹️ Application stopped by user")
81
+ except Exception as e:
82
+ print(f"❌ Error running application: {e}")
83
+ return False
84
+
85
+ return True
86
+
87
+ if __name__ == "__main__":
88
+ print("πŸ”§ BytePlus Image Generation Studio - Setup & Run")
89
+ print("=" * 50)
90
+
91
+ setup_directories()
92
+ print("\n" + "=" * 50)
93
+
94
+ if len(sys.argv) > 1 and sys.argv[1] == "--setup-only":
95
+ print("βœ… Setup complete. Directories are now accessible.")
96
+ print("To run the app: python run_app.py")
97
+ else:
98
+ run_app()