Spaces:
Runtime error

Hidayatmahar's picture
Update app.py
6cf973d verified
Raw History Blame Contribute Delete
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()