Open MoezFalomen opened 2 years ago
@yfszzx The text parsing part of this feature could be done with something like this:
import re
input = "1---3.0dde, 5, 7,9, 15-20, 2" # Messing with spaces, too many dashes, duplicate numbers and decimals to stress test the code
out = ""
for ii in re.sub('[^0123456789,-.]', '', input).replace(" ", "").split(","):
out += re.sub('[^0123456789,-]', '', re.sub('--+', '-', re.sub('\\.\\d+$', '', ii))) + ","
input = out[:-1].split(",")
numbers = []
for i in input:
if "-" in i:
start, end = i.split("-")
numbers += range(int(start), int(end) + 1)
else:
numbers.append(int(i))
numbers.sort() # So the list looks nice, not necessary
numbers = list(set(numbers)) # Remove duplicates
print(numbers)
You would also need to change your gr.Number
input to a gr.Textbox
.
Then the array should be sent to a slightly modified version of your delete function.
Feature request:
It would be good to select multiple images to delete. This can be done by selecting the images from the Web GUI or specifying indices (i.e.
1,2,3
or1-10,32,45
). This will be particularly useful for Colab notebooks.