itsJasminZWIN commited on
Commit
afbfecc
·
verified ·
1 Parent(s): 68d689b

Upload 6 files

Browse files
.gitattributes CHANGED
@@ -33,3 +33,8 @@ saved_model/**/* filter=lfs diff=lfs merge=lfs -text
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
 
 
 
 
 
 
33
  *.zip filter=lfs diff=lfs merge=lfs -text
34
  *.zst filter=lfs diff=lfs merge=lfs -text
35
  *tfevents* filter=lfs diff=lfs merge=lfs -text
36
+ example_images/000002.png filter=lfs diff=lfs merge=lfs -text
37
+ example_images/000011.jpg filter=lfs diff=lfs merge=lfs -text
38
+ example_images/000048.png filter=lfs diff=lfs merge=lfs -text
39
+ example_images/Chihiro_13.PNG filter=lfs diff=lfs merge=lfs -text
40
+ example_images/Kiki_01.PNG filter=lfs diff=lfs merge=lfs -text
app.py ADDED
@@ -0,0 +1,48 @@
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
 
1
+ import gradio as gr
2
+ from transformers import pipeline
3
+
4
+ # Load your fine-tuned ViT model
5
+ vit_classifier = pipeline("image-classification", model="itsJasminZWIN/chihiro-classifier")
6
+
7
+ # Load CLIP zero-shot model
8
+ clip_detector = pipeline(model="openai/clip-vit-base-patch32", task="zero-shot-image-classification")
9
+
10
+ # Labels for both models
11
+ label_names = ['chihiro', 'not chihiro']
12
+
13
+ # Define classification function
14
+ def classify_character(image):
15
+ # Run ViT classifier
16
+ vit_results = vit_classifier(image)
17
+ vit_output = {res['label']: round(res['score'], 4) for res in vit_results}
18
+
19
+ # Run CLIP zero-shot classifier
20
+ clip_results = clip_detector(image, candidate_labels=label_names)
21
+ clip_output = {res['label']: round(res['score'], 4) for res in clip_results}
22
+
23
+ return {
24
+ "ViT Classification": vit_output,
25
+ "CLIP Zero-Shot Classification": clip_output
26
+ }
27
+
28
+ # Optional: Example images from your project (use actual image paths or URLs)
29
+ example_images = [
30
+ ["example_images/Chihiro_13.PNG"],
31
+ ["example_images/000048.png"],
32
+ ["example_images/000011.jpg"],
33
+ ["example_images/000002.png."],
34
+ ["example_images/Kiki_01.PNG"]
35
+
36
+ ]
37
+
38
+ # Create Gradio interface
39
+ iface = gr.Interface(
40
+ fn=classify_character,
41
+ inputs=gr.Image(type="filepath"),
42
+ outputs=gr.JSON(),
43
+ title="Chihiro Classifier: ViT vs. CLIP",
44
+ description="Upload an image to see if it's Chihiro or not, using both a fine-tuned ViT model and CLIP zero-shot comparison.",
45
+ examples=example_images
46
+ )
47
+
48
+ iface.launch()
example_images/000002.png ADDED

Git LFS Details

  • SHA256: 7ca960d57275e2059d369cd7c9e688e60460104049fe9cd8311e02d240c8666a
  • Pointer size: 131 Bytes
  • Size of remote file: 404 kB
example_images/000011.jpg ADDED

Git LFS Details

  • SHA256: 430fc2f69b79e270b120f07a5d8210098e5c52ee8cfeda1d10e36abcc8735a75
  • Pointer size: 131 Bytes
  • Size of remote file: 791 kB
example_images/000048.png ADDED

Git LFS Details

  • SHA256: db8ca0504a3445a86b4a7e26a5d649fcbdc720800ca7cfecbc79e9df7d0d05b7
  • Pointer size: 131 Bytes
  • Size of remote file: 588 kB
example_images/Chihiro_13.PNG ADDED

Git LFS Details

  • SHA256: 565e870a518e6f5002a7900d5f0ba1dfcf23aa6b39c10c6afc9140dc84897db9
  • Pointer size: 132 Bytes
  • Size of remote file: 1.37 MB
example_images/Kiki_01.PNG ADDED

Git LFS Details

  • SHA256: 39154eeaf727ab586ce8d9f800a039dc37671ca77244657ab731a4d800b58e98
  • Pointer size: 131 Bytes
  • Size of remote file: 780 kB