mike23415 commited on
Commit
6585a69
·
verified ·
1 Parent(s): 2eb47b3

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +4 -6
app.py CHANGED
@@ -5,24 +5,22 @@ from flask import Flask, request, jsonify
5
  from diffusers import StableDiffusionPipeline # Placeholder; adjust based on SF3D docs
6
  from PIL import Image
7
  import logging
8
- import os
9
- from huggingface_hub import HfFolder
10
 
11
  logging.basicConfig(level=logging.INFO)
12
  logger = logging.getLogger(__name__)
13
 
14
  app = Flask(__name__)
15
 
16
- # Load the model once at startup (on CPU) with authentication
17
  try:
18
  logger.info("Loading Stable Fast 3D pipeline...")
19
- # Use your Hugging Face token (set as environment variable or hardcoded for testing)
20
- token = os.getenv("HF_TOKEN") or "your_hf_token_here" # Replace with your token
21
  pipe = StableDiffusionPipeline.from_pretrained(
22
  "stabilityai/stable-fast-3d",
23
  torch_dtype=torch.float32,
24
  cache_dir="/tmp/hf_home",
25
- token=token, # Pass token for authentication
26
  )
27
  pipe.to("cpu")
28
  logger.info("=== Application Startup at CPU mode =====")
 
5
  from diffusers import StableDiffusionPipeline # Placeholder; adjust based on SF3D docs
6
  from PIL import Image
7
  import logging
 
 
8
 
9
  logging.basicConfig(level=logging.INFO)
10
  logger = logging.getLogger(__name__)
11
 
12
  app = Flask(__name__)
13
 
14
+ # Load the model once at startup (on CPU) with token in code
15
  try:
16
  logger.info("Loading Stable Fast 3D pipeline...")
17
+ # Replace 'your_hf_token_here' with your actual Hugging Face token
18
+ token = "your_hf_token_here" # Hardcoded token for authentication
19
  pipe = StableDiffusionPipeline.from_pretrained(
20
  "stabilityai/stable-fast-3d",
21
  torch_dtype=torch.float32,
22
  cache_dir="/tmp/hf_home",
23
+ token=token, # Pass token directly
24
  )
25
  pipe.to("cpu")
26
  logger.info("=== Application Startup at CPU mode =====")