| # Install required libraries | |
| !pip install transformers torch gradio | |
| # Import necessary libraries | |
| from transformers import pipeline | |
| import gradio as gr | |
| # Load the pre-trained radiography model | |
| model = pipeline("image-to-text", model="forestav/unsloth_vision_radiography_finetune") | |
| # Function to analyze an uploaded radiography image | |
| def analyze_radiography(image): | |
| result = model(image) | |
| return result[0]['generated_text'] | |
| # Create Gradio interface | |
| interface = gr.Interface( | |
| fn=analyze_radiography, | |
| inputs="image", | |
| outputs="text", | |
| title="Radiography Failure Detector", | |
| description="Upload a radiography image to detect defects." | |
| ) | |
| # Launch the app | |
| interface.launch() | |