Minor changes on app.py
Browse files26 unmodified lines2728293030313233333435363637383939404142434465 unmodified lines1101111121111131141151164 unmodified lines12112212312212312412512612512612712812913013126 unmodified lines json.dump(state, f)
def list_available_models():
"""List all .pth models in the models directory"""
"""List all .pth models in the models directory in reverse order"""
if not os.path.exists(MODELS_DIR):
return []
return [f for f in os.listdir(MODELS_DIR) if f.endswith('.pth')]
models = [f for f in os.listdir(MODELS_DIR) if f.endswith('.pth')]
return sorted(models, reverse=True)
def get_hf_model_list():
"""Get list of model files from HuggingFace repository"""
"""Get list of model files from HuggingFace repository in reverse order"""
try:
files = list_repo_files(HF_REPO_ID)
return [f.split('/')[-1] for f in files if f.startswith('models/') and f.endswith('.pth')]
models = [f.split('/')[-1] for f in files if f.startswith('models/') and f.endswith('.pth')]
return sorted(models, reverse=True)
except Exception as e:
print(f"Error fetching models from HuggingFace: {str(e)}")
return []65 unmodified lines fn=lambda x: "No models found in ./models directory. Please train a model first.",
inputs="image",
outputs="text",
title="TeLVE - Turkish efficient Language Vision Engine",
title="TeLVE - Turkish efficient Language Vision Engine 🧿",
description="Error: No models available"
)
4 unmodified lines gr.Dropdown(choices=available_models, label="Select Model", value=available_models[0])
],
outputs=gr.Textbox(label="Generated Caption"),
title="TeLVE - Turkish Language Vision Encoder",
description="Upload an image to generate a Turkish caption.",
title="TeLVE - Turkish efficient Language Vision Engine 🧿",
description="Upload an image to generate a Turkish description.",
examples=[
["./images/example1.jpg", available_models[0]],
["./images/example2.jpg", available_models[0]]
["./images/mugla.jpg", available_models[0]],
["./images/example.jpg", available_models[0]]
] if os.path.exists("./images") else None
)
return interfaceapp.py+11-9