geyik1 commited on
Commit
2b2ad31
·
verified ·
1 Parent(s): e90dae4

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +40 -0
app.py ADDED
@@ -0,0 +1,40 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ import torch
3
+ from huggingface_hub import HfApi, login
4
+ import os
5
+
6
+ # Force CPU usage if needed
7
+ device = "cuda" if torch.cuda.is_available() else "cpu"
8
+ print(f"Using device: {device}")
9
+
10
+ # Login to Hugging Face with token
11
+ hf_token = os.getenv("HUGGINGFACE_TOKEN")
12
+ if hf_token:
13
+ login(token=hf_token)
14
+ else:
15
+ print("Warning: HUGGINGFACE_TOKEN environment variable not set")
16
+
17
+ def load_model():
18
+ try:
19
+ interface = gr.Interface.load(
20
+ "models/goofyai/3d_render_style_xl"
21
+ )
22
+ return interface
23
+ except Exception as e:
24
+ print(f"Error loading model: {str(e)}")
25
+ return None
26
+
27
+ # Create the interface
28
+ try:
29
+ interface = load_model()
30
+ if interface:
31
+ interface.launch(
32
+ share=False,
33
+ server_name="0.0.0.0",
34
+ server_port=7860,
35
+ show_error=True
36
+ )
37
+ else:
38
+ print("Failed to load the interface")
39
+ except Exception as e:
40
+ print(f"Error launching interface: {str(e)}")