Spaces:
Runtime error
Runtime error
SuperPunk2077
commited on
Commit
·
9dd2b91
1
Parent(s):
6c85583
Update app.py
Browse files
app.py
CHANGED
@@ -6,117 +6,26 @@ def greet(name):
|
|
6 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
7 |
iface.launch()
|
8 |
|
9 |
-
|
10 |
-
import time
|
11 |
-
from skimage import io, color
|
12 |
-
from PIL import Image
|
13 |
-
from io import BytesIO
|
14 |
-
from skimage.io import imread, imsave
|
15 |
-
import imutils
|
16 |
|
17 |
-
|
18 |
-
PATH_TO_FILES = '/home/ekene/Documents/working/ChoiceData/imglb2017/'
|
19 |
|
20 |
-
|
21 |
-
from glob import glob
|
22 |
-
import cv2
|
23 |
-
import datetime
|
24 |
-
import sys
|
25 |
-
import os
|
26 |
-
import string
|
27 |
-
import warnings
|
28 |
-
from os.path import join
|
29 |
-
import matplotlib.pyplot as plt
|
30 |
|
31 |
-
|
32 |
-
timestamp = datetime.datetime.now().strftime("%Y%m%d-%H%M%S%f")
|
33 |
-
print("Initialising...")
|
34 |
-
if len(argv) == 2:
|
35 |
-
filename = argv[1]
|
36 |
-
full_path = PATH_TO_FILES + filename
|
37 |
-
img = imread(full_path)
|
38 |
|
39 |
-
|
40 |
-
img = cv2.resize(img, (scale_image, scale_image))
|
41 |
|
42 |
-
|
43 |
-
#otsu = cv2.threshold(gray, 0, 255, cv2.THRESH_BINARY+cv2.THRESH_OTSU)
|
44 |
-
#img = cv2.cvtColor(otsu, cv2.COLOR_GRAY2BGR)
|
45 |
|
46 |
-
|
47 |
-
h, w = gray.shape[:2]
|
48 |
-
cv_he = cv2.equalizeHist(gray)
|
49 |
-
#cv2.imshow('HE', cv_he)
|
50 |
|
|
|
51 |
|
52 |
-
|
53 |
|
54 |
-
|
55 |
|
56 |
-
|
57 |
-
# keep only contours that are larger than 10% of the image area
|
58 |
-
# (here we assume the largest contour will be around the "head")
|
59 |
|
60 |
-
|
61 |
-
|
62 |
-
#calculate distance between each contour and sort contours by distance
|
63 |
-
# print(filtered_contours, contours)
|
64 |
-
closest_contours = sorted(filtered_contours, key = cv2.contourArea, reverse=True)
|
65 |
-
closest_contours = closest_contours[:4]
|
66 |
-
# selected_contours = closest_contours
|
67 |
-
|
68 |
-
# sort by smallest contour area
|
69 |
-
#filtered_contours = sorted(filtered_contours, key = cv2.contourArea, reverse=True)
|
70 |
-
|
71 |
-
# used for testing
|
72 |
-
if len(filtered_contours) > 1:
|
73 |
-
return 0
|
74 |
-
cv2.drawContours(gray, [filtered_contours[0]], -1, (255,255,255), 2)
|
75 |
-
cv2.drawContours(gray, filtered_contours, -1, (255,255,255), 2)
|
76 |
-
cv2.imshow("search by smallest area", gray)
|
77 |
-
cv2.waitKey(0)
|
78 |
-
|
79 |
-
return 0
|
80 |
-
|
81 |
-
# adding to show a function image
|
82 |
-
|
83 |
-
def show_image(frame):
|
84 |
-
plt.subplot(1,2,1)
|
85 |
-
plt.title('Original Image')
|
86 |
-
plt.imshow(frame, cmap='gray')
|
87 |
-
plt.subplot(1,2,2)
|
88 |
-
plt.title('Image with contours drawn')
|
89 |
-
plt.imshow(frame, cmap='gray')
|
90 |
-
plt.show()
|
91 |
-
return 0
|
92 |
-
|
93 |
-
def image_face_detection(path_to_image):
|
94 |
-
|
95 |
-
# Initialise the trackbar
|
96 |
-
cv2.namedWindow('Frame')
|
97 |
-
cv2.namedWindow('Threshold')
|
98 |
-
|
99 |
-
current_image = cv2.imread(path_to_image)
|
100 |
-
|
101 |
-
frame = current_image
|
102 |
-
# threshold_trackbar = cv2.createTrackbar('Threshold', 'Frame', 51, 255, nothing)
|
103 |
-
# cv2.createTrackbar('Threshold', 'Frame', 100, 255, nothing)
|
104 |
-
# cv2.createTrackbar('Threshold', 'Frame', 130, 255, nothing)
|
105 |
-
# cv2.createTrackbar('Threshold', 'Frame', 150, 255, nothing)
|
106 |
-
# cv2.createTrackbar('Threshold', 'Frame', 90, 255, nothing)
|
107 |
-
# cv2.createTrackbar('Threshold', 'Frame', 180, 255, nothing)
|
108 |
-
|
109 |
-
#cv2.namedWindow("Frame")
|
110 |
-
#cv2.createTrackbar('Threshold', "Frame", 50, 255, nothing)
|
111 |
-
|
112 |
-
# Initialize the first frame, resize the window, start the timer
|
113 |
-
# first_time = True
|
114 |
-
first_time = True
|
115 |
-
# start_clock = time.time()
|
116 |
-
# main_loop()
|
117 |
-
# print('Run time ', time.time()-start_clock)
|
118 |
-
start_clock = time.time()
|
119 |
-
|
120 |
-
# Capture keyboard events
|
121 |
-
key = cv2.waitKey(1) & 0xFF
|
122 |
-
# Press space to pause or unpause the video
|
|
|
6 |
iface = gr.Interface(fn=greet, inputs="text", outputs="text")
|
7 |
iface.launch()
|
8 |
|
9 |
+
( deft loadpath ( image ) ( string ( path [ :args ( get image () )))) (load path ( icon ( loadpath ( image ))))
|
|
|
|
|
|
|
|
|
|
|
|
|
10 |
|
11 |
+
In the case of ai ImageLoader.c:
|
|
|
12 |
|
13 |
+
import ImageLoader
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
14 |
|
15 |
+
import ImageLoader [ loadImageFromImage ( images )))
|
|
|
|
|
|
|
|
|
|
|
|
|
16 |
|
17 |
+
import System.IO
|
|
|
18 |
|
19 |
+
import Data.Csv
|
|
|
|
|
20 |
|
21 |
+
let images = [ ] for loadPath in args [ 0 ]:
|
|
|
|
|
|
|
22 |
|
23 |
+
let path = os . path . split ( ' #' )
|
24 |
|
25 |
+
( path [ 1 :] [ 2 :] [ 3 :] ) ,
|
26 |
|
27 |
+
path ( loadPath ( image ))
|
28 |
|
29 |
+
( loadPath ( icon ( loadpath ( image )))))
|
|
|
|
|
30 |
|
31 |
+
( loadPath ( icon ( loadpath ( image )))))
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|