prensofslavs commited on
Commit
bff9789
·
verified ·
1 Parent(s): fdf2275

Update app.py

Browse files
Files changed (1) hide show
  1. app.py +3 -48
app.py CHANGED
@@ -12,37 +12,8 @@ logger = logging.getLogger(__name__)
12
  current_dir = os.path.dirname(os.path.abspath(__file__))
13
  sys.path.append(current_dir)
14
 
15
- def find_model_path():
16
- """Find the model path based on environment and available paths"""
17
- # Check common model paths
18
- possible_paths = [
19
- "/home/user/model/unsloth_model",
20
- "/model/unsloth_model",
21
- "/model",
22
- "model/unsloth_model",
23
- os.path.join(os.path.dirname(current_dir), "model/unsloth_model"),
24
- ]
25
-
26
- for path in possible_paths:
27
- if os.path.exists(path):
28
- logger.info(f"Found model at path: {path}")
29
- # Check if it has adapter files
30
- files = os.listdir(path)
31
- if "adapter_model.safetensors" in files and "adapter_config.json" in files:
32
- logger.info(f"Found adapter model at: {path}")
33
- return path
34
- elif "config.json" in files and any(f.endswith(".safetensors") or f.endswith(".bin") for f in files):
35
- logger.info(f"Found full model at: {path}")
36
- return path
37
-
38
- logger.warning("Could not find model files, using HF model")
39
- return "NousResearch/Llama-2-7b-chat-hf"
40
-
41
  def main():
42
  parser = argparse.ArgumentParser(description="Freudian Dream Analyzer Interface")
43
- parser.add_argument("--model_path", type=str,
44
- default=None, # Will be set based on environment
45
- help="Path to the fine-tuned model or HF model ID")
46
  parser.add_argument("--share", action="store_true",
47
  help="Create a shareable link")
48
  parser.add_argument("--debug", action="store_true",
@@ -76,25 +47,9 @@ def main():
76
  else:
77
  raise
78
 
79
- # Determine model path
80
- if args.model_path is None:
81
- model_path = find_model_path()
82
- else:
83
- model_path = args.model_path
84
- if not os.path.exists(model_path) and not model_path.startswith("Nous"):
85
- logger.warning(f"Specified model path {model_path} does not exist.")
86
- model_path = find_model_path()
87
-
88
- logger.info(f"Using model path: {model_path}")
89
-
90
- # Check if we need to install additional requirements
91
- try:
92
- import peft
93
- logger.info("PEFT library already installed")
94
- except ImportError:
95
- logger.warning("PEFT library not found, installing...")
96
- os.system("pip install -q peft")
97
- logger.info("PEFT installation completed")
98
 
99
  # Create the interface
100
  try:
 
12
  current_dir = os.path.dirname(os.path.abspath(__file__))
13
  sys.path.append(current_dir)
14
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
15
  def main():
16
  parser = argparse.ArgumentParser(description="Freudian Dream Analyzer Interface")
 
 
 
17
  parser.add_argument("--share", action="store_true",
18
  help="Create a shareable link")
19
  parser.add_argument("--debug", action="store_true",
 
47
  else:
48
  raise
49
 
50
+ # Use a dummy path - our new interface ignores it and uses a CPU-compatible model
51
+ model_path = "dummy_path"
52
+ logger.info(f"Using dummy model path for CPU-compatible model")
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
53
 
54
  # Create the interface
55
  try: