Spaces:
Runtime error
Runtime error
measmonysuon
commited on
Commit
•
81ead26
1
Parent(s):
5c4fa07
Update app.py
Browse files
app.py
CHANGED
@@ -3,7 +3,7 @@ from gradio_client import Client
|
|
3 |
import os
|
4 |
import logging
|
5 |
import requests
|
6 |
-
from huggingface_hub import login, whoami
|
7 |
import torch
|
8 |
|
9 |
webhook_server = os.getenv('webhook_server')
|
@@ -15,6 +15,8 @@ API_TOKEN = os.getenv('ZeroGPU')
|
|
15 |
|
16 |
# Set your token
|
17 |
login(token=API_TOKEN, add_to_git_credential=True)
|
|
|
|
|
18 |
|
19 |
# Initialize the client for image generation "prithivMLmods/IMAGINEO-4K" "mukaist/DALLE-4K"
|
20 |
client_image = Client("measmonysuon/DALLE-4K")
|
@@ -37,6 +39,7 @@ logging.basicConfig(level=logging.INFO)
|
|
37 |
logger = logging.getLogger(__name__)
|
38 |
|
39 |
def generate_image(prompt, resolution_key, style=DEFAULT_STYLE):
|
|
|
40 |
resolution = resolutions.get(resolution_key, (1024, 1024))
|
41 |
width, height = resolution
|
42 |
full_prompt = f"{prompt}, Canon EOS R5, 4K, Photo-Realistic, appearing photorealistic with super fine details, high resolution, natural look, hyper realistic photography, cinematic lighting, --ar 64:37, --v 6.0, --style raw, --stylize 750"
|
@@ -55,9 +58,11 @@ def generate_image(prompt, resolution_key, style=DEFAULT_STYLE):
|
|
55 |
api_name="/run"
|
56 |
)
|
57 |
logger.info("Image generation successful.")
|
|
|
58 |
return result
|
59 |
except Exception as e:
|
60 |
logger.error(f"Error generating image: {e}")
|
|
|
61 |
return None
|
62 |
|
63 |
def request_otp(user_chat_id):
|
|
|
3 |
import os
|
4 |
import logging
|
5 |
import requests
|
6 |
+
from huggingface_hub import login, whoami, HfFolder, HfApi, SpaceHardware
|
7 |
import torch
|
8 |
|
9 |
webhook_server = os.getenv('webhook_server')
|
|
|
15 |
|
16 |
# Set your token
|
17 |
login(token=API_TOKEN, add_to_git_credential=True)
|
18 |
+
# Initialize API client
|
19 |
+
api = HfApi(token=HF_TOKEN)
|
20 |
|
21 |
# Initialize the client for image generation "prithivMLmods/IMAGINEO-4K" "mukaist/DALLE-4K"
|
22 |
client_image = Client("measmonysuon/DALLE-4K")
|
|
|
39 |
logger = logging.getLogger(__name__)
|
40 |
|
41 |
def generate_image(prompt, resolution_key, style=DEFAULT_STYLE):
|
42 |
+
api.request_space_hardware(repo_id='measmonysuon/DALLE-4K', hardware='a10g-large')
|
43 |
resolution = resolutions.get(resolution_key, (1024, 1024))
|
44 |
width, height = resolution
|
45 |
full_prompt = f"{prompt}, Canon EOS R5, 4K, Photo-Realistic, appearing photorealistic with super fine details, high resolution, natural look, hyper realistic photography, cinematic lighting, --ar 64:37, --v 6.0, --style raw, --stylize 750"
|
|
|
58 |
api_name="/run"
|
59 |
)
|
60 |
logger.info("Image generation successful.")
|
61 |
+
api.request_space_hardware(repo_id='measmonysuon/DALLE-4K', hardware='zero-a10g')
|
62 |
return result
|
63 |
except Exception as e:
|
64 |
logger.error(f"Error generating image: {e}")
|
65 |
+
api.request_space_hardware(repo_id='measmonysuon/DALLE-4K', hardware='zero-a10g')
|
66 |
return None
|
67 |
|
68 |
def request_otp(user_chat_id):
|