Spaces:
Runtime error
Runtime error
| import gradio as gr | |
| import random | |
| import time | |
| from typing import List, Dict, Tuple | |
| # Mock data for demonstration | |
| PANELISTS = [ | |
| "Alex (Art Student)", "Bella (Biologoy Major)", "Chloe (Computer Science)", "Dani (Dance)", "Emma (Engineering)", | |
| "Fiona (Fashion)", "Grace (Gaming)", "Hana (History)", "Isla (Illustration)", "Jade (Journalism)" | |
| ] | |
| def validate_content(content_data) -> Tuple[bool, str]: | |
| """ | |
| Basic content validation - in a real app, this would integrate with | |
| proper moderation services | |
| """ | |
| # Placeholder for actual content validation | |
| return True, "Content validated" | |
| def generate_rating(content_type: str, user_stats: Dict = None) -> Dict: | |
| """Generate mock ratings for demonstration purposes""" | |
| # Simulate AI analysis | |
| time.sleep(1) | |
| # Generate random but structured feedback | |
| score = random.randint(1, 10) | |
| effort_rating = random.randint(1, 10) | |
| feedback_types = [ | |
| "Technical assessment", "Aesthetic evaluation", | |
| "Comparative analysis", "Creative feedback" | |
| ] | |
| return { | |
| "overall_score": score, | |
| "effort_rating": effort_rating, | |
| } | |
| def process_upload(file_data, user_stats: str = None) -> str: | |
| """ | |
| Process user upload with proper validation | |
| """ | |
| # Validate content | |
| is_valid, message = validate_content(file_data) | |
| if not is_valid: | |
| return f"Validation failed: {message}" | |
| else: | |
| rating_data = generate_rating("image", user_stats) | |
| return f"Rating: {rating_data['overall_score']}/10 - {message}" | |
| return "Content processed successfully" | |
| # Create the main application | |
| with gr.Blocks() as demo: | |
| gr.Markdown("# Content Evaluation Platform") | |
| gr.Markdown("A structured platform for creative content assessment") | |
| with gr.Tab("Upload Content"): | |
| with gr.Row(): | |
| with gr.Column(): | |
| upload_input = gr.File( | |
| label="Upload your content", | |
| file_types=["image", "video"], | |
| type="filepath" | |
| ) | |
| stats_input = gr.Textbox( | |
| label="Additional context (optional)", | |
| placeholder="Provide any relevant details..." | |
| ) | |
| submit_btn = gr.Button("Submit for Rating", variant="primary") | |
| with gr.Column(): | |
| rating_output = gr.Textbox( | |
| label="Assessment Result", | |
| lines=4 | |
| ) | |
| submit_btn.click( | |
| fn=process_upload, | |
| inputs=[upload_input, stats_input], | |
| outputs=rating_output, | |
| api_visibility="private" | |
| ) | |
| with gr.Tab("Rating Guidelines"): | |
| gr.Markdown(""" | |
| ## Evaluation Framework | |
| **Focus Areas:** | |
| - Technical execution | |
| - Creative expression | |
| - Overall impact | |
| **Rating Scale:** | |
| 1-3: Needs development | |
| 4-6: Solid foundation | |
| 7-9: Exceptional work | |
| 10: Masterpiece | |
| """) | |
| gr.Markdown( | |
| "[Built with anycoder](https://huggingface.co/spaces/akhaliq/anycoder)" | |
| ) | |
| # Launch with modern Gradio 6 theme | |
| demo.launch( | |
| theme=gr.themes.Soft( | |
| primary_hue="blue", | |
| secondary_hue="indigo", | |
| font=gr.themes.GoogleFont("Inter"), | |
| text_size="lg", | |
| spacing_size="lg" | |
| ) |