Spaces:
Sleeping
Sleeping
File size: 1,996 Bytes
71c32d5 e0edb69 71c32d5 e0edb69 71c32d5 |
1 2 3 4 5 6 7 8 9 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 |
import gradio as gr
import os
from simple_classifier import SimpleRockClassifier
classifier = SimpleRockClassifier()
def analyze_core(image):
"""Analyze a drill core image"""
# Save uploaded image temporarily
temp_path = "temp_upload.jpg"
image.save(temp_path)
# Get prediction
try:
result = classifier.predict(temp_path)
# Format response
response = f"""
## Drill Core Analysis Results
### Primary Prediction
**Rock Type:** `{result['rock_type']}`
**Confidence:** `{result['confidence']:.2f}`
### Analysis Details
{result['explanation']}
"""
except Exception as e:
response = f"## Error\nAn error occurred during analysis: {str(e)}"
if os.path.exists(temp_path):
os.remove(temp_path)
return response
# Create Gradio interface
with gr.Blocks(title="Geologist_AI - Core Logger") as demo:
gr.Markdown("# Geologist_AI - Core Logger")
gr.Markdown("Upload a drill core image to identify the rock type")
with gr.Row():
with gr.Column():
image_input = gr.Image(type="pil", label="π· Drill Core Image")
submit_btn = gr.Button("π Analyze Core Sample", variant="primary")
with gr.Column():
output_text = gr.Markdown(label="π Analysis Results")
submit_btn.click(
fn=analyze_core,
inputs=image_input,
outputs=output_text
)
gr.Markdown("---")
gr.Markdown("### About this Tool")
gr.Markdown("""
This AI-powered geologist identifies rock types based on:
- **Visual color analysis**
- **Deep learning feature extraction**
**Supported rock types:**
- Gold-bearing rock
- Iron-rich rock
- Lithium-rich rock
- Copper-bearing rock
- Quartz-rich rock
- Waste rock
""")
# Launch the app
if __name__ == "__main__":
demo.launch()
|