Download app.py from Nassira/REALCOMP: direct link, hf CLI and curl.
- Browser
- Download file 2.23 kB
-
https://huggingface.co/spaces/Nassira/REALCOMP/resolve/main/app.py
- Command line
-
hf download hf://spaces/Nassira/REALCOMP/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Nassira/REALCOMP/resolve/main/app.py
2.23 kB
| import streamlit as st | |
| import asyncio | |
| import json | |
| from cv_analyzer import process_cv | |
| st.set_page_config(page_title="CV Analyzer", page_icon="📄", layout="wide") | |
| def cached_process_cv(_file): | |
| return None # Cette fonction ne fait rien maintenant, mais permet de conserver le cache pour le fichier | |
| def display_section(title, content): | |
| st.write(f"**{title}**") | |
| st.write(content) | |
| async def analyze_cv(file): | |
| return await process_cv(file) | |
| def main(): | |
| st.title("CV Analyzer") | |
| uploaded_file = st.file_uploader("Choose a CV file", type=["pdf", "png", "jpg", "jpeg"]) | |
| if uploaded_file: | |
| # Utiliser le cache pour vérifier si le fichier a déjà été analysé | |
| cache_key = cached_process_cv(uploaded_file) | |
| with st.spinner("Analyzing CV..."): | |
| try: | |
| # Exécuter l'analyse de manière asynchrone | |
| result = asyncio.run(analyze_cv(uploaded_file)) | |
| col1, col2 = st.columns(2) | |
| with col1: | |
| display_section("Personal Information", f"Score: {result['personalInfo']['score']}/{result['personalInfo']['max_score']}") | |
| st.json(result["personalInfo"]["info"]) | |
| display_section("Spelling and Grammar", f"Error %: {result['spellingGrammar']['error_percentage']:.2f}%\nScore: {result['spellingGrammar']['score']}/{result['spellingGrammar']['max_score']}") | |
| with col2: | |
| display_section("Completeness", f"Score: {result['completeness']['score']}/{result['completeness']['max_score']}") | |
| st.write("Present Sections:") | |
| st.json(result['completeness']['present_sections']) | |
| display_section("Content Quality", "") | |
| for section, quality in result["contentQuality"].items(): | |
| st.write(f"{section}: {quality['overall_score']:.1f}/{quality['max_score']}") | |
| st.subheader(f"Total Score: {result['totalScore']:.1f}/{result['maxTotalScore']}") | |
| except Exception as e: | |
| st.error(f"An error occurred during analysis: {str(e)}") | |
| if __name__ == "__main__": | |
| main() |