geyik1 commited on
Commit
57d9e12
·
verified ·
1 Parent(s): f58c70f

Upload app.py

Browse files
Files changed (1) hide show
  1. app.py +41 -0
app.py ADDED
@@ -0,0 +1,41 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
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
+ alias="game-icon-generator"
22
+ )
23
+ return interface
24
+ except Exception as e:
25
+ print(f"Error loading model: {str(e)}")
26
+ return None
27
+
28
+ # Create the interface
29
+ try:
30
+ interface = load_model()
31
+ if interface:
32
+ interface.launch(
33
+ share=False,
34
+ server_name="0.0.0.0",
35
+ server_port=7860,
36
+ show_error=True
37
+ )
38
+ else:
39
+ print("Failed to load the interface")
40
+ except Exception as e:
41
+ print(f"Error launching interface: {str(e)}")