geyik1 commited on
Commit
e452f55
·
verified ·
1 Parent(s): 31b51e9

Delete app.py

Browse files
Files changed (1) hide show
  1. app.py +0 -69
app.py DELETED
@@ -1,69 +0,0 @@
1
- import gradio as gr
2
- import torch
3
- from huggingface_hub import HfApi, login
4
- import os
5
- import sys
6
- import traceback
7
-
8
- # Force CPU usage if needed
9
- device = "cuda" if torch.cuda.is_available() else "cpu"
10
- print(f"Using device: {device}")
11
-
12
- # More details about the environment
13
- print(f"Gradio version: {gr.__version__}")
14
- print(f"Python version: {sys.version}")
15
-
16
- # Login to Hugging Face with token
17
- hf_token = os.getenv("HUGGINGFACE_TOKEN")
18
- if hf_token:
19
- login(token=hf_token)
20
- print("Successfully logged in to Hugging Face Hub")
21
- else:
22
- print("Warning: HUGGINGFACE_TOKEN environment variable not set")
23
-
24
- def load_model():
25
- try:
26
- print("Attempting to load model from Hugging Face Hub...")
27
- # Attempt to use HfApi to check if the model exists
28
- api = HfApi()
29
- try:
30
- # Check if model exists
31
- model_info = api.model_info("goofyai/3d_render_style_xl")
32
- print(f"Found model: {model_info.modelId}")
33
- except Exception as e:
34
- print(f"Error checking model info: {str(e)}")
35
-
36
- # Try a different approach with the newer Gradio API
37
- try:
38
- print("Using gr.load() method...")
39
- interface = gr.load("models/goofyai/3d_render_style_xl")
40
- return interface
41
- except Exception as e:
42
- print(f"Error with gr.load(): {str(e)}")
43
- print(traceback.format_exc())
44
-
45
- # Try the older Interface.load method as fallback
46
- print("Trying Interface.load() as fallback...")
47
- interface = gr.Interface.load("models/goofyai/3d_render_style_xl")
48
- return interface
49
- except Exception as e:
50
- print(f"Error loading model: {str(e)}")
51
- print(traceback.format_exc())
52
- return None
53
-
54
- # Create the interface
55
- try:
56
- interface = load_model()
57
- if interface:
58
- print("Model loaded successfully, launching interface...")
59
- interface.launch(
60
- share=False,
61
- server_name="0.0.0.0",
62
- server_port=7860,
63
- show_error=True
64
- )
65
- else:
66
- print("Failed to load the interface")
67
- except Exception as e:
68
- print(f"Error launching interface: {str(e)}")
69
- print(traceback.format_exc())