Skip to content

Commit

Permalink
Paused aparte y minor changes
Browse files Browse the repository at this point in the history
  • Loading branch information
Moibe committed Dec 19, 2024
1 parent 59f41a7 commit ce94e34
Show file tree
Hide file tree
Showing 6 changed files with 13 additions and 16 deletions.
8 changes: 6 additions & 2 deletions funciones.py
Original file line number Diff line number Diff line change
Expand Up @@ -47,8 +47,12 @@ def perform(input1, request: gr.Request):
#MASS es la que ejecuta la aplicación EXTERNA
def mass(input1):

api, tipo_api = tools.elijeAPI()
print("Una vez elegido API, el tipo api es: ", tipo_api)
if globales.same_api == False: #Si son diferentes apis, realiza el proceso de selección.
api, tipo_api = tools.elijeAPI()
print("Una vez elegido API, el tipo api es: ", tipo_api)
else: #Si no, deja la primera y no corras ningun proceso.
api = globales.api_zero
tipo_api = "cost"

client = gradio_client.Client(api, hf_token=bridges.hug)
#client = gradio_client.Client("https://058d1a6dcdbaca0dcf.gradio.live/") #MiniProxy
Expand Down
3 changes: 2 additions & 1 deletion globales.py
Original file line number Diff line number Diff line change
@@ -1,13 +1,14 @@
import gradio as gr

#MAIN
version = "5.14.18"
version = "5.15.18"
env = "dev"
aplicacion = "superheroes-dev" #como se llama en tu repo y tu dominio.

#api = "Moibe/splashmix"
api_zero = "Moibe/InstantID2" #Risky but leave @ 25.
api_cost = "Moibe/InstantID2-B" #Corriendo en Zero, 22 segundos. Quota limitada.
same_api = False #Hay diferencia en las apis por eso si se debe correr proceso de selección.
#api = "charlieguo610/InstantID" #Corriendo en A10G, 22 segundos. Libre!!
#api = "InstantX/InstantID" #Como es externa pide 60s.

Expand Down
4 changes: 2 additions & 2 deletions sulkuFront.py
Original file line number Diff line number Diff line change
Expand Up @@ -49,7 +49,7 @@ def visualizar_creditos(nuevos_creditos, usuario):

#Controla lo que se depliega en el frontend y que tiene que ver con llamados a Sulku.
def noCredit(usuario):
info_window = "Out of credits..."
info_window = sulkuMessages.out_of_credits
path = 'images/no-credits.png'
tokens = 0
html_credits = visualizar_creditos(tokens, usuario)
Expand Down Expand Up @@ -79,7 +79,7 @@ def manejadorExcepciones(excepcion):
info_window = sulkuMessages.NO_FACE
elif excepcion == "NO_FILE":
info_window = sulkuMessages.NO_FILE
elif excepcion == "NO_POSITION":
elif excepcion == "NO_POSITION": #Solo aplíca para Splashmix.
info_window = sulkuMessages.NO_POSITION
elif "quota" in excepcion: #Caso especial porque el texto cambiará citando la cuota.
info_window = excepcion
Expand Down
1 change: 0 additions & 1 deletion sulkuMessages.py
Original file line number Diff line number Diff line change
Expand Up @@ -10,5 +10,4 @@
NO_FACE = "Unable to detect a face in the image. Please upload a different photo with a clear face."
NO_POSITION = "Missing body position calculation, please contact me, no credits were debited."
GENERAL = "Network error, no credits were debited."

ELSE = "Error. No credits were debited."
5 changes: 1 addition & 4 deletions sulkuPypi.py
Original file line number Diff line number Diff line change
Expand Up @@ -59,7 +59,6 @@ def getTokens(userfile, env):

if response.status_code == 200:
tokens = response.json()
#print("Conexión a Sulku successful, tokens: ", tokens)
else:
error = f"Error al obtener el elemento todo: {response.status_code}"
return error
Expand Down Expand Up @@ -87,9 +86,7 @@ def debitTokens(userfile, work, env):

method = "debitTokens/"
params = userfile + "/" + work + "/" + env

api_url = base_url + method + params

api_url = base_url + method + params
response = requests.get(api_url)


Expand Down
8 changes: 2 additions & 6 deletions tools.py
Original file line number Diff line number Diff line change
Expand Up @@ -6,8 +6,6 @@
import sulkuPypi
import time



def theme_selector():
temas_posibles = [
gr.themes.Base(),
Expand All @@ -30,7 +28,7 @@ def initAPI(api):
runtime = llave.get_space_runtime(repo_id=repo_id)
print("Stage: ", runtime.stage)
#"RUNNING_BUILDING", "APP_STARTING", "SLEEPING", "RUNNING", "PAUSED", "RUNTIME_ERROR"
if runtime.stage == "SLEEPING" or runtime.stage == "PAUSED":
if runtime.stage == "SLEEPING":
llave.restart_space(repo_id=repo_id)
print("Despertando")
print("Hardware: ", runtime.hardware)
Expand All @@ -44,7 +42,6 @@ def initAPI(api):
return result_from_initAPI

def titulizaExcepDeAPI(e):
print("Éstoy en tituliza y ésta esla excepción que traigo hoy: ", e)
#Resume una excepción a un título manejable.
if "RUNTIME_ERROR" in str(e):
resultado = "RUNTIME_ERROR" #api mal construida tiene error.
Expand Down Expand Up @@ -97,8 +94,7 @@ def desTuplaResultado(resultado):
print(resultado)
ruta_imagen_local = resultado[0]
print("Ésto es resultado ruta imagen local: ", ruta_imagen_local)
return ruta_imagen_local

return ruta_imagen_local

#NO PROCESO CORRECTAMENTE NO GENERA UNA TUPLA.
#CORRIGE IMPORTANTE: QUE NO SE SALGA DEL CICLO DE ESA IMAGEN AL ENCONTRAR ERROR.
Expand Down

0 comments on commit ce94e34

Please sign in to comment.