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