sdas2485 commited on
Commit
89c8472
·
verified ·
1 Parent(s): 0049c6d

Create app.py

Browse files
Files changed (1) hide show
  1. app.py +26 -0
app.py ADDED
@@ -0,0 +1,26 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ # Install required libraries
2
+ !pip install transformers torch gradio
3
+
4
+ # Import necessary libraries
5
+ from transformers import pipeline
6
+ import gradio as gr
7
+
8
+ # Load the pre-trained radiography model
9
+ model = pipeline("image-to-text", model="forestav/unsloth_vision_radiography_finetune")
10
+
11
+ # Function to analyze an uploaded radiography image
12
+ def analyze_radiography(image):
13
+ result = model(image)
14
+ return result[0]['generated_text']
15
+
16
+ # Create Gradio interface
17
+ interface = gr.Interface(
18
+ fn=analyze_radiography,
19
+ inputs="image",
20
+ outputs="text",
21
+ title="Radiography Failure Detector",
22
+ description="Upload a radiography image to detect defects."
23
+ )
24
+
25
+ # Launch the app
26
+ interface.launch()