drdata commited on
Commit
4ece2db
Β·
verified Β·
1 Parent(s): 780f03f

Upload folder using huggingface_hub

Browse files
.gitattributes CHANGED
@@ -37,6 +37,3 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
37
  Assets/Ghibli.jpg filter=lfs diff=lfs merge=lfs -text
38
  Assets/Picasso.jpg filter=lfs diff=lfs merge=lfs -text
39
  Assets/VanGogh.jpg filter=lfs diff=lfs merge=lfs -text
40
- hf_deploy/Assets/Ghibli.jpg filter=lfs diff=lfs merge=lfs -text
41
- hf_deploy/Assets/Picasso.jpg filter=lfs diff=lfs merge=lfs -text
42
- hf_deploy/Assets/VanGogh.jpg filter=lfs diff=lfs merge=lfs -text
 
37
  Assets/Ghibli.jpg filter=lfs diff=lfs merge=lfs -text
38
  Assets/Picasso.jpg filter=lfs diff=lfs merge=lfs -text
39
  Assets/VanGogh.jpg filter=lfs diff=lfs merge=lfs -text
 
 
 
Generated/README.md ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # Generated
2
+
3
+ Placeholder to ensure this directory is tracked.
__pycache__/app.cpython-313.pyc ADDED
Binary file (16 kB). View file
 
app.py CHANGED
@@ -8,9 +8,53 @@ import importlib.util
8
  from dotenv import load_dotenv
9
  load_dotenv()
10
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
11
  def create_symlinks_to_real_folders(cache_dir):
12
  """Create symbolic links in cache directory to real folders in main workspace."""
13
- main_workspace = Path("/Users/data/SGS-1")
 
14
 
15
  # Define the folders that need symbolic links
16
  folders_to_link = ["Generated", "static", "view_session"]
@@ -24,6 +68,9 @@ def create_symlinks_to_real_folders(cache_dir):
24
  link_path = cache_dir / folder_name
25
 
26
  try:
 
 
 
27
  # Remove existing file/folder/link if it exists
28
  if link_path.exists() or link_path.is_symlink():
29
  if link_path.is_symlink():
@@ -237,28 +284,6 @@ def download_space(cache_dir):
237
  token = os.environ.get("HF_TOKEN")
238
  repo_id = os.environ.get("REPO_ID")
239
 
240
- if not token or not repo_id:
241
- print("❌ HF_TOKEN or REPO_ID not found in environment variables")
242
- return False
243
-
244
- try:
245
- print(f"πŸ“₯ Downloading BytePlus space: {repo_id}")
246
- snapshot_download(
247
- repo_id=repo_id,
248
- repo_type="space",
249
- local_dir=cache_dir,
250
- token=token
251
- )
252
- print("βœ… Successfully downloaded BytePlus space")
253
- return True
254
- except Exception as e:
255
- print(f"❌ Error downloading space: {e}")
256
- return False
257
- def download_space(cache_dir):
258
- """Download the BytePlus space from HuggingFace."""
259
- token = os.environ.get("HF_TOKEN")
260
- repo_id = os.environ.get("REPO_ID")
261
-
262
  if not token or not repo_id:
263
  print("❌ HF_TOKEN or REPO_ID not found in environment variables")
264
  return False
@@ -351,11 +376,14 @@ def load_app(cache_dir):
351
  )
352
 
353
  if __name__ == "__main__":
354
- print("πŸš€ Setting up BytePlus Image Generation Studio with symbolic links...")
355
 
356
  # Setup cache directory
357
  cache_dir = setup_cache_directory()
358
  print(f"πŸ“ Cache directory: {cache_dir}")
 
 
 
359
 
360
  # Download the space
361
  if download_space(cache_dir):
 
8
  from dotenv import load_dotenv
9
  load_dotenv()
10
 
11
+ def ensure_root_directories(main_workspace: Path) -> None:
12
+ """Create required root-level folders and subfolders before any symlinks.
13
+
14
+ Folders: Generated/, static/{css,js,images}/, view_session/
15
+ Also drops a .gitkeep in each to ensure they can be tracked in a repo.
16
+ """
17
+ print("πŸ—οΈ Creating root-level directories (before symlinking)...")
18
+ required = [
19
+ main_workspace / "Generated",
20
+ main_workspace / "static",
21
+ main_workspace / "static" / "css",
22
+ main_workspace / "static" / "js",
23
+ main_workspace / "static" / "images",
24
+ main_workspace / "view_session",
25
+ ]
26
+
27
+ for d in required:
28
+ try:
29
+ # If a symlink exists at the path, replace it with a real directory
30
+ if d.is_symlink():
31
+ try:
32
+ d.unlink()
33
+ print(f"πŸ” Replaced symlink with real directory: {d}")
34
+ except Exception as e:
35
+ print(f"⚠️ Could not remove symlink {d}: {e}")
36
+ # Ensure directory exists
37
+ d.mkdir(parents=True, exist_ok=True)
38
+ try:
39
+ d.chmod(0o755)
40
+ except Exception:
41
+ pass
42
+ # Add README.md so directories are tracked per current .gitignore rules
43
+ try:
44
+ readme = d / "README.md"
45
+ if not readme.exists():
46
+ rel = d.relative_to(main_workspace)
47
+ readme.write_text(f"# {rel}\n\nPlaceholder to ensure this directory is tracked.\n")
48
+ except Exception:
49
+ pass
50
+ print(f"βœ… Ensured directory: {d}")
51
+ except Exception as e:
52
+ print(f"⚠️ Warning: could not ensure {d}: {e}")
53
+
54
  def create_symlinks_to_real_folders(cache_dir):
55
  """Create symbolic links in cache directory to real folders in main workspace."""
56
+ # Use the directory containing this script as root workspace
57
+ main_workspace = Path(__file__).parent.resolve()
58
 
59
  # Define the folders that need symbolic links
60
  folders_to_link = ["Generated", "static", "view_session"]
 
68
  link_path = cache_dir / folder_name
69
 
70
  try:
71
+ # Ensure real folder exists (defensive)
72
+ real_folder.mkdir(parents=True, exist_ok=True)
73
+
74
  # Remove existing file/folder/link if it exists
75
  if link_path.exists() or link_path.is_symlink():
76
  if link_path.is_symlink():
 
284
  token = os.environ.get("HF_TOKEN")
285
  repo_id = os.environ.get("REPO_ID")
286
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
287
  if not token or not repo_id:
288
  print("❌ HF_TOKEN or REPO_ID not found in environment variables")
289
  return False
 
376
  )
377
 
378
  if __name__ == "__main__":
379
+ print("πŸš€ Setting up BytePlus Image Generation Studio with root directories + symlinks...")
380
 
381
  # Setup cache directory
382
  cache_dir = setup_cache_directory()
383
  print(f"πŸ“ Cache directory: {cache_dir}")
384
+
385
+ # Ensure root directories exist first (as requested)
386
+ ensure_root_directories(Path(__file__).parent.resolve())
387
 
388
  # Download the space
389
  if download_space(cache_dir):
app_security.log CHANGED
@@ -37,3 +37,6 @@
37
  2025-09-24 23:53:42,587 - httpx - INFO - HTTP Request: GET http://127.0.0.1:7860/gradio_api/startup-events "HTTP/1.1 200 OK"
38
  2025-09-24 23:53:42,655 - httpx - INFO - HTTP Request: HEAD http://127.0.0.1:7860/ "HTTP/1.1 200 OK"
39
  2025-09-24 23:53:43,139 - httpx - INFO - HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
 
 
 
 
37
  2025-09-24 23:53:42,587 - httpx - INFO - HTTP Request: GET http://127.0.0.1:7860/gradio_api/startup-events "HTTP/1.1 200 OK"
38
  2025-09-24 23:53:42,655 - httpx - INFO - HTTP Request: HEAD http://127.0.0.1:7860/ "HTTP/1.1 200 OK"
39
  2025-09-24 23:53:43,139 - httpx - INFO - HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
40
+ 2025-09-25 01:14:56,553 - httpx - INFO - HTTP Request: GET http://127.0.0.1:7860/gradio_api/startup-events "HTTP/1.1 200 OK"
41
+ 2025-09-25 01:14:56,571 - httpx - INFO - HTTP Request: HEAD http://127.0.0.1:7860/ "HTTP/1.1 200 OK"
42
+ 2025-09-25 01:14:57,265 - httpx - INFO - HTTP Request: GET https://api.gradio.app/pkg-version "HTTP/1.1 200 OK"
static/README.md ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # static
2
+
3
+ Placeholder to ensure this directory is tracked.
view_session/README.md ADDED
@@ -0,0 +1,3 @@
 
 
 
 
1
+ # view_session
2
+
3
+ Placeholder to ensure this directory is tracked.