Spaces:
Runtime error
Runtime error
Download app.py from Hidayatmahar/course-allocation: direct link, hf CLI and curl.
- Browser
- Download file 1.55 kB
-
https://huggingface.co/spaces/Hidayatmahar/course-allocation/resolve/main/app.py
- Command line
-
hf download hf://spaces/Hidayatmahar/course-allocation/app.py
-
curl -L -o app.py https://huggingface.co/spaces/Hidayatmahar/course-allocation/resolve/main/app.py
1.55 kB
| import gradio as gr | |
| # Function to collect the data | |
| def collect_course_allocation(faculty_name, faculty_photo, subject_name, course_type, credit_hours, department_name): | |
| # Check if the faculty photo is uploaded | |
| if faculty_photo is None: | |
| return "Please upload a faculty photo!", None | |
| # Store or process the data | |
| result = f"Department: {department_name}\nFaculty Name: {faculty_name}\nSubject: {subject_name}\n" | |
| result += f"Course Type: {course_type}\nCredit Hours: {credit_hours}\n" | |
| # Display faculty photo | |
| photo_message = f"Faculty Photo: {faculty_photo.name}" | |
| return result, faculty_photo | |
| # Create the form inputs | |
| department_name = gr.Textbox(label="Department Name", placeholder="Enter the department name") | |
| faculty_name = gr.Textbox(label="Faculty Name", placeholder="Enter the faculty name") | |
| faculty_photo = gr.Image(type="pil", label="Upload Faculty Photo") # Ensure image type is correct (PIL image) | |
| subject_name = gr.Textbox(label="Subject Name", placeholder="Enter the subject name") | |
| course_type = gr.Radio(choices=["Theory", "Lab"], label="Course Type") | |
| credit_hours = gr.Number(label="Credit Hours", min_value=1, max_value=5, value=3) | |
| submit_button = gr.Button("Submit") | |
| # Set up Gradio interface | |
| iface = gr.Interface( | |
| fn=collect_course_allocation, | |
| inputs=[department_name, faculty_name, faculty_photo, subject_name, course_type, credit_hours], | |
| outputs=[gr.Textbox(label="Course Allocation Details"), gr.Image(label="Faculty Photo")], | |
| live=True | |
| ) | |
| iface.launch() | |