Re: Where did the message go?
On 16/06/21 4:47 am, Chris Angelico wrote: On Wed, Jun 16, 2021 at 2:41 AM Grimble wrote: > was bouncing because haydn.. was not a registered subdomain with my ISP, whereas bach.. was registered. > > I like your naming convention :) Weirdly, the first association "haydn" triggered in my brain was a local company that I have professional dealings with. Only when I read a bit further did I realise it was referring to the composer! -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: Help with Python circular error
On Wednesday, 16 June 2021 at 10:32:50 UTC+2, Arak Rachael wrote: > On Tuesday, 15 June 2021 at 19:30:28 UTC+2, Chris Angelico wrote: > > On Wed, Jun 16, 2021 at 3:17 AM MRAB wrote: > > > > > > On 2021-06-15 17:49, Chris Angelico wrote: > > > > On Wed, Jun 16, 2021 at 2:45 AM Arak Rachael > > > > wrote: > > > >> > > > >> Hi to everyone, > > > >> > > > >> I am having a problem with this error, I created a package and > > > >> uploaded it to Test PyPi, but I can not get it to work, can someone > > > >> help me please? > > > >> > > > >> https://test.pypi.org/manage/project/videotesting/releases/' > > > >> > > > >> The error: > > > >> > > > >> /home/user/anaconda3/envs/testing/bin/python > > > >> /home/user/devel/python.assignments/topgis-viz/topgis-test.py > > > >> Traceback (most recent call last): > > > >> File "/home/user/devel/python.assignments/topgis-viz/topgis-test.py", > > > >> line 10, in > > > >> from videotesting import downsample_and_save_npz > > > >> File > > > >> "/home/user/anaconda3/envs/testing/lib/python3.8/site-packages/videotesting/__init__.py", > > > >> line 7, in > > > >> from videotesting import extract_video > > > >> ImportError: cannot import name 'extract_video' from partially > > > >> initialized module 'videotesting' (most likely due to a circular > > > >> import) > > > >> (/home/user/anaconda3/envs/testing/lib/python3.8/site-packages/videotesting/__init__.py) > > > >> > > > >> > > > > > > > > Hard to diagnose without the source code, but I'm thinking that your > > > > __init__.py is probably trying to import from elsewhere in the > > > > package? If so, try "from . import extract_video" instead. > > > > > > > Well, the traceback says that videotesting/__init__.py has: > > > from videotesting import extract_video > > > > > > so it is trying to import from itself during initialisation. > > Yes, but what we can't tell is what the intention is. It could be > > trying to import from its own package (in which case my suggestion > > would be correct), or it could be trying to import from something > > completely different (in which case the solution is to rename > > something to avoid the conflict). Or it could be something else > > entirely. > > > > ChrisA > Thanks all! > > > I have __init__.py in the create and uploaded package and I have __init_.py > in the new package, which is not ready yet. Its 2 projects, but I am using > project 1 into project 2. > > Here is the first package as a .zip > https://www.dropbox.com/s/lkz0qf4mq9afpaz/video-testing-package1.zip?dl=0 > > Here is the second project in which I try to use the first one: > https://www.dropbox.com/s/sxjpip23619fven/topgis-viz-package2.zip?dl=0 The problems were 2: 1. This has to be in __init__.py: import pipreqs import cv2 import numpy import os import PIL #import videotesting from .videotest import extract_video from .videotest import resize_and_grayscale from .videotest import add_progress_bar from .videotest import downsample_and_save_npz the dots before videotest are critical 2. The module is named videotest as the file videotest.py, not videotesting -- https://mail.python.org/mailman/listinfo/python-list
Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?
Greg Ewing 在 2021年6月16日 星期三上午7:11:35 [UTC+8] 的信中寫道: > On 15/06/21 7:32 pm, Jach Feng wrote: > > But usually the list creation is not in simple way:-) for example: > a = [1,2] > m = [a for i in range(3)] > m > > [[1, 2], [1, 2], [1, 2]] > id(m[0]) == id(m[1]) == id(m[2]) > > True > The first line is only executed once, so you just get one > list object [1, 2]. You then refer to that object three times > when you build the outer list. > > To get three different [1, 2] lists you would need something > like this: > m = [[1,2] for i in range(3)] > This executes the [1, 2] expression 3 times. Because lists are > mutable, you can be sure that this will give you 3 distinct > list objects. > > -- > Greg Yes, I know. Here I just want to show another gutter I had found:-). Anyone else? --Jach -- https://mail.python.org/mailman/listinfo/python-list
SettingWithCopyWarning despite df.loc
Hi,
I have read a CSV file into a pandas DataFrame. The data contain a
column for disk-space usage in KB. To plot the data, I would like to
scale the date to, say, GB. What I have is the following:
size_unit = "GB"
factor = {"GB": 1/(1024*1024)}
usage.loc[:, size_unit] = usage.loc[:, 'KB']
usage.loc[:, size_unit] = usage.loc[:, size_unit] * factor[size_unit]
This works, but I get the warning:
SettingWithCopyWarning:
A value is trying to be set on a copy of a slice from a DataFrame.
Try using .loc[row_indexer,col_indexer] = value instead
See the caveats in the documentation:
http://pandas.pydata.org/pandas-docs/stable/user_guide/indexing.html#returning-a-view-versus-a-copy
self.obj[item] = s
I added the .loc stuff after getting the same warning from my naive
attempts at copying and modifying an existing column and then trying to
understand the information pointed to by the URL. However, I don't see
what my example has to do with "chained indexing" and why what I now
have is still wrong.
Can anyone illuminate me?
Cheers,
Loris
--
This signature is currently under construction.
--
https://mail.python.org/mailman/listinfo/python-list
Re: Help with Python circular error
On Tuesday, 15 June 2021 at 19:30:28 UTC+2, Chris Angelico wrote: > On Wed, Jun 16, 2021 at 3:17 AM MRAB wrote: > > > > On 2021-06-15 17:49, Chris Angelico wrote: > > > On Wed, Jun 16, 2021 at 2:45 AM Arak Rachael > > > wrote: > > >> > > >> Hi to everyone, > > >> > > >> I am having a problem with this error, I created a package and uploaded > > >> it to Test PyPi, but I can not get it to work, can someone help me > > >> please? > > >> > > >> https://test.pypi.org/manage/project/videotesting/releases/' > > >> > > >> The error: > > >> > > >> /home/user/anaconda3/envs/testing/bin/python > > >> /home/user/devel/python.assignments/topgis-viz/topgis-test.py > > >> Traceback (most recent call last): > > >> File "/home/user/devel/python.assignments/topgis-viz/topgis-test.py", > > >> line 10, in > > >> from videotesting import downsample_and_save_npz > > >> File > > >> "/home/user/anaconda3/envs/testing/lib/python3.8/site-packages/videotesting/__init__.py", > > >> line 7, in > > >> from videotesting import extract_video > > >> ImportError: cannot import name 'extract_video' from partially > > >> initialized module 'videotesting' (most likely due to a circular import) > > >> (/home/user/anaconda3/envs/testing/lib/python3.8/site-packages/videotesting/__init__.py) > > >> > > >> > > > > > > Hard to diagnose without the source code, but I'm thinking that your > > > __init__.py is probably trying to import from elsewhere in the > > > package? If so, try "from . import extract_video" instead. > > > > > Well, the traceback says that videotesting/__init__.py has: > > from videotesting import extract_video > > > > so it is trying to import from itself during initialisation. > Yes, but what we can't tell is what the intention is. It could be > trying to import from its own package (in which case my suggestion > would be correct), or it could be trying to import from something > completely different (in which case the solution is to rename > something to avoid the conflict). Or it could be something else > entirely. > > ChrisA Thanks all! I have __init__.py in the create and uploaded package and I have __init_.py in the new package, which is not ready yet. Its 2 projects, but I am using project 1 into project 2. Here is the first package as a .zip https://www.dropbox.com/s/lkz0qf4mq9afpaz/video-testing-package1.zip?dl=0 Here is the second project in which I try to use the first one: https://www.dropbox.com/s/sxjpip23619fven/topgis-viz-package2.zip?dl=0 -- https://mail.python.org/mailman/listinfo/python-list
Re: optimization of rule-based model on discrete variables
Il Wed, 16 Jun 2021 11:37:42 +1200, Greg Ewing ha scritto: > On 15/06/21 10:07 pm, Elena wrote: >> After the optimization, I will use f just to predict new Xi. > > So you're going to use f backwards? > > I don't see how that will work. Where are you going to find a new yi to > feed into the inverse of f? > > I think I don't understand what role g plays in all of this. If the > ultimate goal is to find a better mixture, > you need some kind of figure of merit for an individual mixture. But you > don't have that, you only have this thing g that somehow depends on all > of your mixtures at once. > > I'm still not seeing the big picture. sorry I wrote it wrongly, my bad, I will use f just to predict yi from new coming Xi. -- https://mail.python.org/mailman/listinfo/python-list
tkinter: tksheet
Reading the doc for tksheet tells me that it allows me to modify cells (or entire rows) as well as display them. What I don't see is whether I can add a new row using tksheet and change the column used for sorting (e.g., sorting by company number or company name). If you have experience with tksheet perhaps you can answer my questions about it's capabilities. Rich -- https://mail.python.org/mailman/listinfo/python-list
Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?
Chris Angelico wrote at 2021-6-16 02:20 +1000: >On Wed, Jun 16, 2021 at 2:18 AM Dieter Maurer wrote: >> As far as I know, there are no guarantees are the language level. >> There are some (partially documented) implementation details >> for CPython (which is just one possible implementation). > >Yes there are - plenty of them :) The example I gave is a language >guarantee. Would you point to the documentation location where this is guaranteed? -- Dieter -- https://mail.python.org/mailman/listinfo/python-list
Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?
On Thu, Jun 17, 2021 at 2:32 AM Dieter Maurer wrote: > > Chris Angelico wrote at 2021-6-16 02:20 +1000: > >On Wed, Jun 16, 2021 at 2:18 AM Dieter Maurer wrote: > >> As far as I know, there are no guarantees are the language level. > >> There are some (partially documented) implementation details > >> for CPython (which is just one possible implementation). > > > >Yes there are - plenty of them :) The example I gave is a language > >guarantee. > > Would you point to the documentation location where this is guaranteed? > Probably somewhere in the tutorial where object identity is explained? Not sure. It's pretty fundamental. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
How to check if an image contains an element I am searchig for
Hi guys, I have an image from google maps to say and I need to check if it has road markings, in order to do that, I believe I need to change the effects on the image so the markings and road can be white or something and the things I don't need like cars, trees and so on to be black. images should contain only road surface and/or road markings (lines, zebras, stripes. Can anyone help me on this, I already have the crop code, I just need to check if the cropped part contains what I need. -- https://mail.python.org/mailman/listinfo/python-list
Re: optimization of rule-based model on discrete variables
On 16/06/21 10:51 pm, Elena wrote: sorry I wrote it wrongly, my bad, I will use f just to predict yi from new coming Xi. Then what do you do with the new yi? -- Greg -- https://mail.python.org/mailman/listinfo/python-list
Re: tkinter: tksheet
On 6/16/2021 12:31 PM, Rich Shepard wrote: Reading the doc for tksheet tells me that it allows me to modify cells (or entire rows) as well as display them. What I don't see is whether I can add a new row using tksheet Somewhat sparse doc at https://github.com/ragardner/tksheet/blob/master/DOCUMENTATION.md#5-modifying-table-data insert_row() and change the column used for sorting (e.g., sorting by company number or company name). I did not see anything about sorting. tksheet is generic 'table', not a database viewer -- Terry Jan Reedy -- https://mail.python.org/mailman/listinfo/python-list
Re: How to check if an image contains an element I am searchig for
On Thu, Jun 17, 2021 at 6:06 AM Arak Rachael wrote: > > Hi guys, > > I have an image from google maps to say and I need to check if it has road > markings, in order to do that, I believe I need to change the effects on the > image so the markings and road can be white or something and the things I > don't need like cars, trees and so on to be black. > > images should contain only road surface and/or road markings (lines, zebras, > stripes. > > Can anyone help me on this, I already have the crop code, I just need to > check if the cropped part contains what I need. How well can you define the things you're looking for? https://xkcd.com/1425/ ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?
Dieter Maurer schreef op 16/06/2021 om 18:32: Chris Angelico wrote at 2021-6-16 02:20 +1000: On Wed, Jun 16, 2021 at 2:18 AM Dieter Maurer wrote: As far as I know, there are no guarantees are the language level. There are some (partially documented) implementation details for CPython (which is just one possible implementation). Yes there are - plenty of them :) The example I gave is a language guarantee. Would you point to the documentation location where this is guaranteed? I lost track of which exact guarantee we're discussing here. In any case, the documentation for the id() function ([1]) says: "This is an integer which is guaranteed to be unique and constant for this object during its lifetime. Two objects with non-overlapping lifetimes may have the same id() value. CPython implementation detail: This is the address of the object in memory." Does that answer your doubts? [1] https://docs.python.org/3.8/library/functions.html?highlight=id#id -- "Honest criticism is hard to take, particularly from a relative, a friend, an acquaintance, or a stranger." -- Franklin P. Jones Roel Schroeven -- https://mail.python.org/mailman/listinfo/python-list
Re: How to check if an image contains an element I am searchig for
On Wednesday, 16 June 2021 at 22:08:31 UTC+2, Chris Angelico wrote: > On Thu, Jun 17, 2021 at 6:06 AM Arak Rachael wrote: > > > > Hi guys, > > > > I have an image from google maps to say and I need to check if it has road > > markings, in order to do that, I believe I need to change the effects on > > the image so the markings and road can be white or something and the things > > I don't need like cars, trees and so on to be black. > > > > images should contain only road surface and/or road markings (lines, > > zebras, stripes. > > > > Can anyone help me on this, I already have the crop code, I just need to > > check if the cropped part contains what I need. > How well can you define the things you're looking for? > > https://xkcd.com/1425/ > > ChrisA Hi Chris, what do you mean? Here is the image, I need to separate the road and markings from the rest and divide the image into squares of 100x100 pixels, for each square I need to check if it contains a road and markings: https://www.dropbox.com/s/iduxj0j8w0ic616/SatelliteProcessing_Image.png?dl=0 -- https://mail.python.org/mailman/listinfo/python-list
Re: tkinter: tksheet
On Wed, 16 Jun 2021, Terry Reedy wrote: Somewhat sparse doc at https://github.com/ragardner/tksheet/blob/master/DOCUMENTATION.md#5-modifying-table-data insert_row() Terry, I'm reading this now and saw that. and change the column used for sorting (e.g., sorting by company number or company name). I did not see anything about sorting. tksheet is generic 'table', not a database viewer The two applications I'm building are both database applications. If tksheet() is not the most appropriate widget to display database tables what alternative would be better? Thanks, Rich -- https://mail.python.org/mailman/listinfo/python-list
Re: How to check if an image contains an element I am searchig for
On Thu, Jun 17, 2021 at 6:44 AM Arak Rachael wrote: > > On Wednesday, 16 June 2021 at 22:08:31 UTC+2, Chris Angelico wrote: > > On Thu, Jun 17, 2021 at 6:06 AM Arak Rachael wrote: > > > > > > Hi guys, > > > > > > I have an image from google maps to say and I need to check if it has > > > road markings, in order to do that, I believe I need to change the > > > effects on the image so the markings and road can be white or something > > > and the things I don't need like cars, trees and so on to be black. > > > > > > images should contain only road surface and/or road markings (lines, > > > zebras, stripes. > > > > > > Can anyone help me on this, I already have the crop code, I just need to > > > check if the cropped part contains what I need. > > How well can you define the things you're looking for? > > > > https://xkcd.com/1425/ > > > > ChrisA > Hi Chris, > > what do you mean? > > Here is the image, I need to separate the road and markings from the rest and > divide the image into squares of 100x100 pixels, for each square I need to > check if it contains a road and markings: > > https://www.dropbox.com/s/iduxj0j8w0ic616/SatelliteProcessing_Image.png?dl=0 > How will a program know if something contains a road? Are you trying to solve captchas? ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: How to check if an image contains an element I am searchig for
> On 16 Jun 2021, at 21:46, Arak Rachael wrote: > > On Wednesday, 16 June 2021 at 22:08:31 UTC+2, Chris Angelico wrote: >>> On Thu, Jun 17, 2021 at 6:06 AM Arak Rachael wrote: >>> >>> Hi guys, >>> >>> I have an image from google maps to say and I need to check if it has road >>> markings, in order to do that, I believe I need to change the effects on >>> the image so the markings and road can be white or something and the things >>> I don't need like cars, trees and so on to be black. >>> >>> images should contain only road surface and/or road markings (lines, >>> zebras, stripes. >>> >>> Can anyone help me on this, I already have the crop code, I just need to >>> check if the cropped part contains what I need. >> How well can you define the things you're looking for? >> >> https://xkcd.com/1425/ >> >> ChrisA > Hi Chris, > > what do you mean? He means that image processing is a hard problem that requires expertise to solve. > > Here is the image, I need to separate the road and markings from the rest and > divide the image into squares of 100x100 pixels, for each square I need to > check if it contains a road and markings: Can you define road in terms of an algorithm that looks at the pixels? > > https://www.dropbox.com/s/iduxj0j8w0ic616/SatelliteProcessing_Image.png?dl=0 > > -- > https://mail.python.org/mailman/listinfo/python-list > -- https://mail.python.org/mailman/listinfo/python-list
Re: Why the list creates in two different ways? Does it cause by the mutability of its elements? Where the Python document explains it?
On 2021-06-16 18:32:46 +0200, Dieter Maurer wrote: > Chris Angelico wrote at 2021-6-16 02:20 +1000: > >On Wed, Jun 16, 2021 at 2:18 AM Dieter Maurer wrote: > >> As far as I know, there are no guarantees are the language level. > >> There are some (partially documented) implementation details > >> for CPython (which is just one possible implementation). > > > >Yes there are - plenty of them :) The example I gave is a language > >guarantee. > > Would you point to the documentation location where this is guaranteed? I think it's in https://docs.python.org/3/reference/expressions.html#atom-identifiers | When the name is bound to an object, evaluation of the atom yields that object. So in x = whatever a_list = [x for _ in range(3)] you get a list of 3 references to the same object, not 3 references to 3 different copies of that object. hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | [email protected] |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" signature.asc Description: PGP signature -- https://mail.python.org/mailman/listinfo/python-list
Re: How to check if an image contains an element I am searchig for
On Thu, Jun 17, 2021 at 7:25 AM Dennis Lee Bieber wrote: > > On Thu, 17 Jun 2021 06:07:59 +1000, Chris Angelico > declaimed the following: > > > >How well can you define the things you're looking for? > > > >https://xkcd.com/1425/ > > Non sequitur comment -- Sounds like a potential usage of a BeagleBone > AI with the TI Deep Learning modules... though I don't think they've > documented how to go from the example learning images to teaching it to > recognize birds Yeah. We have the tools for high-grade AI now, but ultimately, teaching an AI to recognize birds requires someone spending quite a few hours going through photos of birds and drawing boxes around them. "That's a bird. That's a bird. That's a bird. That's not a bird, it's a plane. That's a bird. That's a bird. That's not a bird, it's Superman." > Won't help the OP unless it can be taught to recognize vehicles and > somehow provide coordinates to let the OP "blank out" said vehicles. > > Edge detection might provide some hints -- but simple "same color > pixels" won't -- as the roads may have different colors (concrete vs > asphalt vs gravel vs dirt -- and then you get asphalt/tar patches applied > to pot-holes and cracks in concrete). Also, as in that photo, many of the > vehicles are near enough to the road color that any range used to ensure > picking up variations in the road will pick up the vehicles. > Yup. Image processing is hard. Having seen what people can do with various tools, I can only conclude that (a) the tools are magic, and (b) the job is STILL a big one, even with magical tools. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: How to check if an image contains an element I am searchig for
On Wed, Jun 16, 2021 at 2:04 PM Barry wrote: > >>> On Thu, Jun 17, 2021 at 6:06 AM Arak Rachael > wrote: > >>> > >>> Hi guys, > >>> > >>> I have an image from google maps to say and I need to check if it has > road markings, in order to do that, I believe I need to change the effects > on the image so the markings and road can be white or something and the > things I don't need like cars, trees and so on to be black. > >>> > >>> images should contain only road surface and/or road markings (lines, > zebras, stripes. > >>> > >>> Can anyone help me on this, I already have the crop code, I just need > to check if the cropped part contains what I need. > >> How well can you define the things you're looking for? > >> > >> https://xkcd.com/1425/ > >> > >> ChrisA > > Hi Chris, > > > > what do you mean? > > He means that image processing is a hard problem that requires expertise > to solve. > > > > > Here is the image, I need to separate the road and markings from the > rest and divide the image into squares of 100x100 pixels, for each square I > need to check if it contains a road and markings: > > Can you define road in terms of an algorithm that looks at the pixels? > I think that XKCD may be a little out of date. You could probably train a Deep Learning model to do this, if you have enough prelabeled data with enough variation. And of course dividing a picture up into 100x100 squares is pretty easy if you convert to ppm. Perhaps Pillow can do this too. HTH. -- https://mail.python.org/mailman/listinfo/python-list
Re: How to check if an image contains an element I am searchig for
On Thu, Jun 17, 2021 at 7:35 AM Dan Stromberg wrote: > > On Wed, Jun 16, 2021 at 2:04 PM Barry wrote: > > > >>> On Thu, Jun 17, 2021 at 6:06 AM Arak Rachael > > wrote: > > >>> > > >>> Hi guys, > > >>> > > >>> I have an image from google maps to say and I need to check if it has > > road markings, in order to do that, I believe I need to change the effects > > on the image so the markings and road can be white or something and the > > things I don't need like cars, trees and so on to be black. > > >>> > > >>> images should contain only road surface and/or road markings (lines, > > zebras, stripes. > > >>> > > >>> Can anyone help me on this, I already have the crop code, I just need > > to check if the cropped part contains what I need. > > >> How well can you define the things you're looking for? > > >> > > >> https://xkcd.com/1425/ > > >> > > >> ChrisA > > > Hi Chris, > > > > > > what do you mean? > > > > He means that image processing is a hard problem that requires expertise > > to solve. > > > > > > > > Here is the image, I need to separate the road and markings from the > > rest and divide the image into squares of 100x100 pixels, for each square I > > need to check if it contains a road and markings: > > > > Can you define road in terms of an algorithm that looks at the pixels? > > > > I think that XKCD may be a little out of date. It's not out of date. The task still requires a lot of effort - it's just that the effort is now "preparing a suitable corpus" rather than "figuring out how on earth to do this". Even with all the tools at our disposal, there's still a stark (and often surprising) distinction between the easy and the hard. For instance, calculating square roots is pretty hard to do by hand, but computers don't have any trouble with that. But "what's that song about blah blah blah" is incredibly difficult, and if you try to write your own tool to do that (rather than doing what most people would do, and type something into a search engine!), you'll find that it's far easier to just give the job to a human. > You could probably train a Deep Learning model to do this, if you have > enough prelabeled data with enough variation. That is, in fact, the exact difficulty. > And of course dividing a picture up into 100x100 squares is pretty easy if > you convert to ppm. Perhaps Pillow can do this too. Sure, but that's the trivially easy part. And probably not even all that helpful in the scheme of things. ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: tkinter: tksheet
On 17/06/2021 08.45, Rich Shepard wrote: > On Wed, 16 Jun 2021, Terry Reedy wrote: > >> Somewhat sparse doc at >> https://github.com/ragardner/tksheet/blob/master/DOCUMENTATION.md#5-modifying-table-data >> >> insert_row() > > Terry, > > I'm reading this now and saw that. > >> and change the column used for sorting (e.g., >>> sorting by company number or company name). >> >> I did not see anything about sorting. tksheet is generic 'table', not >> a database viewer > > The two applications I'm building are both database applications. If > tksheet() is not the most appropriate widget to display database tables > what > alternative would be better? Use the DBMS by retrieving the data in the desired sequence? -- Regards, =dn -- https://mail.python.org/mailman/listinfo/python-list
Re: tkinter: tksheet
On 16/06/2021 21:45, Rich Shepard wrote: > The two applications I'm building are both database applications. If > tksheet() is not the most appropriate widget to display database tables what > alternative would be better? I've not used tksheet but it sounds like it might be worth investigating. There is a grid in Tix but its quite hard to use and Tix is now deprecated. It was also a bit unreliable when used from Python (that's euphemistic for "I couldn't get it to work!" :-) But there is nothing I know of for Tkinter that provides views of database tables in the way that Delphi or VB or C# do, for example. You have to extract the data using SQL and populate the table and manage all changes (of both view and data) yourself. A good grid component would be a huge boon for tkinter, its one of the most commonly used widgets in VB/Delphi etc A DB-API linked grid would be the height of luxury... If you do a lot of that kind of desktop apps then you could look at Dabo which is built on wxPython but has links to databases. Unfortunately it looks like work ground to a halt about 5 years ago. -- Alan G Author of the Learn to Program web site http://www.alan-g.me.uk/ http://www.amazon.com/author/alan_gauld Follow my photo-blog on Flickr at: http://www.flickr.com/photos/alangauldphotos -- https://mail.python.org/mailman/listinfo/python-list
Re: tkinter: tksheet
On Wed, 16 Jun 2021, Dennis Lee Bieber wrote: Scroll further down to "bindings"... rc_insert_row -- a menu binding Dennis, Yes, I saw that one, too. As for sorting, I don't see anything that allows one to add custom events to the bindings... best I can come up with is that if a header column is selected you sort the data and reload the table. My naive idea is to use two queries, one selects * from the company table ordered by nunber, the other by name. The UI offers two radiobuttons when viewing the results, one for each sort column. Thanks, Rich -- https://mail.python.org/mailman/listinfo/python-list
Re: tkinter: tksheet
On Thu, 17 Jun 2021, dn via Python-list wrote: Use the DBMS by retrieving the data in the desired sequence? dn, Yep. That's what I thought would be the best approach. Thanks, Rich -- https://mail.python.org/mailman/listinfo/python-list
Re: tkinter: tksheet
On Wed, 16 Jun 2021, Alan Gauld via Python-list wrote: But there is nothing I know of for Tkinter that provides views of database tables in the way that Delphi or VB or C# do, for example. Alan, These are all Microsoft tools. I run linux only. You have to extract the data using SQL and populate the table and manage all changes (of both view and data) yourself. From an incomplete reading of the tksheet() doc it looks to be the best way to display tables returned by a SQL query. PyQt5 has a QTableView() that does the job, and it works great for a single table, but apparently not so well with complex joins on multiple tables. When I view my contacts table it needs to includes attributes from the company, people, and contacts tables so I can view all prior contacts with that person. If you do a lot of that kind of desktop apps then you could look at Dabo which is built on wxPython but has links to databases. Unfortunately it looks like work ground to a halt about 5 years ago. Many years ago I used wxPython. For several reasons I decided to learn and use tkinter from now one. One reason is that the application for my clients will run mostly on windows hosts and I want to limit the software they need to install and maintain in order to run it. Regards, Rich -- https://mail.python.org/mailman/listinfo/python-list
Re: How to check if an image contains an element I am searchig for
On Wednesday, 16 June 2021 at 23:44:02 UTC+2, Chris Angelico wrote: > On Thu, Jun 17, 2021 at 7:35 AM Dan Stromberg wrote: > > > > On Wed, Jun 16, 2021 at 2:04 PM Barry wrote: > > > > > >>> On Thu, Jun 17, 2021 at 6:06 AM Arak Rachael > > > wrote: > > > >>> > > > >>> Hi guys, > > > >>> > > > >>> I have an image from google maps to say and I need to check if it has > > > road markings, in order to do that, I believe I need to change the > > > effects > > > on the image so the markings and road can be white or something and the > > > things I don't need like cars, trees and so on to be black. > > > >>> > > > >>> images should contain only road surface and/or road markings (lines, > > > zebras, stripes. > > > >>> > > > >>> Can anyone help me on this, I already have the crop code, I just need > > > to check if the cropped part contains what I need. > > > >> How well can you define the things you're looking for? > > > >> > > > >> https://xkcd.com/1425/ > > > >> > > > >> ChrisA > > > > Hi Chris, > > > > > > > > what do you mean? > > > > > > He means that image processing is a hard problem that requires expertise > > > to solve. > > > > > > > > > > > Here is the image, I need to separate the road and markings from the > > > rest and divide the image into squares of 100x100 pixels, for each square > > > I > > > need to check if it contains a road and markings: > > > > > > Can you define road in terms of an algorithm that looks at the pixels? > > > > > > > I think that XKCD may be a little out of date. > It's not out of date. The task still requires a lot of effort - it's > just that the effort is now "preparing a suitable corpus" rather than > "figuring out how on earth to do this". Even with all the tools at our > disposal, there's still a stark (and often surprising) distinction > between the easy and the hard. > > For instance, calculating square roots is pretty hard to do by hand, > but computers don't have any trouble with that. But "what's that song > about blah blah blah" is incredibly difficult, and if you try to write > your own tool to do that (rather than doing what most people would do, > and type something into a search engine!), you'll find that it's far > easier to just give the job to a human. > > You could probably train a Deep Learning model to do this, if you have > > enough prelabeled data with enough variation. > That is, in fact, the exact difficulty. > > And of course dividing a picture up into 100x100 squares is pretty easy if > > you convert to ppm. Perhaps Pillow can do this too. > Sure, but that's the trivially easy part. And probably not even all > that helpful in the scheme of things. > > ChrisA I understand your concerns. Actually I am doing image processing of satellite pictures for smart cars. I have been given the option to use InfranView and do it manually or create a Python script. -- https://mail.python.org/mailman/listinfo/python-list
Re: How to check if an image contains an element I am searchig for
On 16Jun2021 15:51, Arak Rachael wrote: >I understand your concerns. Actually I am doing image processing of >satellite pictures for smart cars. I have been given the option to use >InfranView and do it manually or create a Python script. If you need to slice images into 100x100 pixels squares, the Pillow module should make that easy. Just looking at InfranView here: https://www.irfanview.com/main_what_is_engl.htm I imagine it can do the same - there's some reference to a batch mode but I have no idea what it can do. Or a shell script using GraphicswMagick or ImageMagick. The hard part is the image classification: does this imagine contain a pedestrian crossing, etc etc etc? Unless InfranView has some outstanding image processing plugin with access to a precatalogued corpus of images I'd be surprised if it will help. This doesn't solve your problem, but it feels like you think there are easy ways to look at a small chunk of an image and analyse its content for high level features. Smart cars need that for hazard recognition etc if they use cameras (eg Teslas, which I believe want to eschew LIDAR for cameras). What little I know of the field says that these things are not easily done. Camera data are full of noise, not geommetricaly aligned with what you're looking for (stripes and various angles, for example), will only have a portion of the feature in view (particularly after cropping into little squares), varying lighting, varying feature colours, people wearing stripey shirts. So an AI approach relies not on semantic knowledge of how things are constructed (rectangular stripes of paint on a raod surface or whatever) but on training a neural net style learner to correlate image measures with categories, in the hope that those measures (and their combinations/correlations) will recognise other objects in the same categories correctly after being fed sufficient images (all correctly precategorised of course). Can you outline how you'd like the Python side to work? It sounds likee you have a batch of images to: - crop into tiles of a particular size (maybe to constraint the compute used per tile) - recognise features in each tile The first part is easily done in Python. The second part is _hard_. Cheers, Cameron Simpson -- https://mail.python.org/mailman/listinfo/python-list
Re: How to check if an image contains an element I am searchig for
On Wed, Jun 16, 2021 at 2:44 PM Chris Angelico wrote: > On Thu, Jun 17, 2021 at 7:35 AM Dan Stromberg wrote: > > > >> How well can you define the things you're looking for? > > > >> > > > >> https://xkcd.com/1425/ > > > >> > > > > He means that image processing is a hard problem that requires > expertise > > > to solve. > > > > > > > > > > > Here is the image, I need to separate the road and markings from the > > > rest and divide the image into squares of 100x100 pixels, for each > square I > > > need to check if it contains a road and markings: > > > > > > Can you define road in terms of an algorithm that looks at the pixels? > > > > > > > I think that XKCD may be a little out of date. > > It's not out of date. The task still requires a lot of effort - it's > just that the effort is now "preparing a suitable corpus" rather than > "figuring out how on earth to do this". Even with all the tools at our > disposal, there's still a stark (and often surprising) distinction > between the easy and the hard. > Well... Are you sure? It's no longer a problem that requires 5 years and a research team. It's now a problem that requires hunting for relevant labeled data, and failing that, paying a small team of unskilled laborers minimum wage to classify images from google images or similar. Plus some programming to create the model and to use it in production. Deep Learning is catching on, in significant part, because lots of useful data is becoming available. Also because hardware is getting faster and the algorithms have improved. Clearly some things are harder than others, but the "hard" example given in the XKCD is no longer really a good example. -- https://mail.python.org/mailman/listinfo/python-list
Re: How to check if an image contains an element I am searchig for
On Thu, Jun 17, 2021 at 4:43 PM Dan Stromberg wrote: > > > > On Wed, Jun 16, 2021 at 2:44 PM Chris Angelico wrote: >> >> On Thu, Jun 17, 2021 at 7:35 AM Dan Stromberg wrote: >> > > >> How well can you define the things you're looking for? >> > > >> >> > > >> https://xkcd.com/1425/ >> > > >> >> >> > > He means that image processing is a hard problem that requires expertise >> > > to solve. >> > > >> > > > >> > > > Here is the image, I need to separate the road and markings from the >> > > rest and divide the image into squares of 100x100 pixels, for each >> > > square I >> > > need to check if it contains a road and markings: >> > > >> > > Can you define road in terms of an algorithm that looks at the pixels? >> > > >> > >> > I think that XKCD may be a little out of date. >> >> It's not out of date. The task still requires a lot of effort - it's >> just that the effort is now "preparing a suitable corpus" rather than >> "figuring out how on earth to do this". Even with all the tools at our >> disposal, there's still a stark (and often surprising) distinction >> between the easy and the hard. > > > Well... Are you sure? > > It's no longer a problem that requires 5 years and a research team. That's because the research years have been done for that particular case. > It's now a problem that requires hunting for relevant labeled data, and > failing that, paying a small team of unskilled laborers minimum wage to > classify images from google images or similar. Plus some programming to > create the model and to use it in production. > > Deep Learning is catching on, in significant part, because lots of useful > data is becoming available. Also because hardware is getting faster and the > algorithms have improved. > > Clearly some things are harder than others, but the "hard" example given in > the XKCD is no longer really a good example. > I don't think it's a bad example. We needed hindsight to be able to figure that out - see the hover text. And it's still much MUCH harder to say "is this thing in this person's hand a gun?" than to say "is this light on?". But as we've seen from all the various voice-command assistants, the difficulty of doing a good job doesn't stop people from doing a bad job... "Close Spotify." // "Okay. Opening Spotify." ChrisA -- https://mail.python.org/mailman/listinfo/python-list
Re: How to check if an image contains an element I am searchig for
On 2021-06-16 15:51:49 -0700, Arak Rachael wrote: > On Wednesday, 16 June 2021 at 23:44:02 UTC+2, Chris Angelico wrote: > > On Thu, Jun 17, 2021 at 7:35 AM Dan Stromberg wrote: > > > > > > On Wed, Jun 16, 2021 at 2:04 PM Barry wrote: > > > > > > > >>> On Thu, Jun 17, 2021 at 6:06 AM Arak Rachael > > > > wrote: > > > > >>> I have an image from google maps to say and I need to check if it > > > > >>> has > > > > road markings, in order to do that, I believe I need to change the > > > > effects > > > > on the image so the markings and road can be white or something and the > > > > things I don't need like cars, trees and so on to be black. [...] > I understand your concerns. Actually I am doing image processing of > satellite pictures for smart cars. Using satellite images probably makes that a lot easier (yes, you wrote "Google maps", but for some reason I thought of Google Street View). At least you have a consistent angle (almost from straight above) and know the scale (given the zoom factor and the latitude). hp -- _ | Peter J. Holzer| Story must make more sense than reality. |_|_) || | | | [email protected] |-- Charles Stross, "Creative writing __/ | http://www.hjp.at/ | challenge!" signature.asc Description: PGP signature -- https://mail.python.org/mailman/listinfo/python-list
