Skip to main content

Posts

One Path to Bankruptcy for Replit

User trying to import a module that's not installed. Instead of bumping him and telling her to use a different workspace on which the module *is* installed, use compute resources to try and install.. nuts.. Starting with : from transformers import TFAutoModelForSeq2SeqLM, AutoTokenizer import gradio as gr model = TFAutoModelForSeq2SeqLM.from_pretrained("google/flan-t5-small") tokenizer = AutoTokenizer.from_pretrained("google/flan-t5-small") def gen_text(input_string, max_length):     inputs = tokenizer(input_string, return_tensors="pt")     outputs = model.generate(**inputs, max_length=max_length)     final_text = tokenizer.batch_decode(outputs[0], skip_special_tokens=True)     return (final_text) demo = gr.Interface(                                                          fn=gen_text,     ...
Recent posts

What Do Generators Give You

Being rusty, I did hands.extend( (b_hand + [card] for card in joker_cards('red')))  And, of course, I actually meant a list comprehension. I actually made myself look better here - I had first done list.append - which gave me a list of lists of lists, rather than a list of lists, which was what I wanted.. if it worked - which it didn't of course - giving me a generator expression. chatGPT told me to wrap the generator expression in list(), which I did - not thinking clearly.. All I needed was: hands.extend( [b_hand + [card] for card in joker_cards('red')] )  Which leads us to the question of generator expressions - what? why? Where?.. What A way to create generators (type of iterable you can use to create lazy sequences) without having to define a function A Genertor function allows you to declare a function that behaves like an iterator - now you can loop around this function call Example (expression for item in ite...

If Using NEdit and Udacity

The problem - Udacity likes to uses only spaces, not tabs for indentation. In NEdit, starting decades ago, you've set it to use tabs or emulated tabs.. Whatever, when you start with code from Udacity and then try running a hacked version in your local python installation, you get "Inconsistent use of Tabs and spaces". Answer? New macro in NEdit - ALT-T that can replace tabs with four spaces in a selection. Just put this in the  nedit.macroCommands: section in your ~/.nedit/nedit.rc file         tab_2_spc:Alt+T::: {\n\                 filter_selection("perl -p -e 's/\\\\t/    /g;'")\n\         }\n

Upwork! Help! Python in My Jupyter Notebook Doesn't See a Module I've Installed

The short summary : "How to shoot yourself in the foot by running Jupyter on two different operating systems simultaneously (on the same computer)" BLUF : Are you sure the notebook in Chrome isn't using a different Jupyter session than you think? Check! What? How? Why?  I got a new work computer, on which I didn't have Administrator rights, to be able to install WSL. (Didn't know *how* to get admin rights 😊). So, being a guy who needs an Excel dashboard and a notebook open all the time, I installed Git bash just to get a flavor of unix (why? Because I can then run my own search engine to search notes for solutions to problems encountered in the past) This gives me Jupyter labs (though I'm happy with plain v Jupe). And I'm kind of hooked. It looks cute. Eventually, I get WSL on there because I need something industrial, not wimpy Git bash that looks like a cygwin under the hood :) And, when the time comes to try hacking, like an openCV course, I nee...

Frank Andrade and Python Automation : All That Can Go Wrong

https://www.youtube.com/embed/PXMJ6FS7llk . Marry why? So I know what's doable and can then go to freelancers on Upwork to build me stuff.. If you haven't already, install lxml before you get thrashed by pd.read_html(). If you're on Python 3, you need to use pip3 >>> pd.read_html( "https://en.wikipedia.org/wiki/List_of_countries_and_dependencies_by_population") --------------------------------------------------------------------------- ImportError Traceback (most recent call last) File ~\AppData\Local\Packages\PythonSoftwareFoundation.Python.3.9_qbz5n2kfra8p0\LocalCache\local-packages\Python39\site-packages\pandas\io\html.py:872, in _parser_dispatch(flavor) 870 else: 871 if not _HAS_LXML: --> 872 raise ImportError("lxml not found, please install it") 873 return _valid_parsers[flavor] ImportError: lxml not found, please install it Suggested by :  https://stackoverflow.com/questions/44...

Popular posts from this blog

Align an Embedded Image in Jupyter Markdown

Nice thing is that you don't have to depend on the image existing as a separate file that you can refer to. You can embed it like an image in an email - you get the idea. Jupyter takes care of this for you in the .ipynb file. But, by default, the image is aligned center and is default size. What if you want to set the size? If it were an external file, then you can just resort to standard HTML. But, you want a fully self contained notebook. So? In one cell, above this one, NOT markdown, but code, have an HTML magic where you specify CSS that applies to this TAG. In the cell of interest, where you insert the image after doing Edit > Insert Image, change the "alt text" inside the [] to something the CSS style can refer to and you're done So, (1) looks like : %%html <style>     img[alt=bad_pie]{         float : left;     } </style> And, the cell with the image, when in edit mode, will look like : ![bad_pie](attachment:Capture.PNG) Than...

openCV : Really Filtering by Color

The free openCV crash course : img_NZ_bgr = cv.imread('New_Zealand_Lake.jpg', cv.IMREAD_COLOR) b,g,r = cv.split(img_NZ_bgr) plt.figure(figsize=[20,5]) plt.subplot(141);plt.imshow(r, cmap='gray');plt.title("Red") plt.subplot(142);plt.imshow(b, cmap='gray');plt.title("Blue") plt.subplot(143);plt.imshow(g, cmap='gray');plt.title("Green") # merging imgMerged = cv.merge((b,g,r)) # original code : b,g,r plt.subplot(144);plt.imshow(imgMerged[...,::-1]);plt.title("Merged") Gives you : Coolie McVoolie. But, wait a minute! Are you really going to fall for that? Remember those "3D" glasses you got in magazines as a kid that let you see the page in 3D by using filters (each eye sees the picture from the required angle)? Meaning, if you're looking at the Red channel, you want to see : This! Right? How? Easy Make a blank channel (basically using NumPy zeros) Use that blank channel for the filtered channels, ...

One Path to Bankruptcy for Replit

User trying to import a module that's not installed. Instead of bumping him and telling her to use a different workspace on which the module *is* installed, use compute resources to try and install.. nuts.. Starting with : from transformers import TFAutoModelForSeq2SeqLM, AutoTokenizer import gradio as gr model = TFAutoModelForSeq2SeqLM.from_pretrained("google/flan-t5-small") tokenizer = AutoTokenizer.from_pretrained("google/flan-t5-small") def gen_text(input_string, max_length):     inputs = tokenizer(input_string, return_tensors="pt")     outputs = model.generate(**inputs, max_length=max_length)     final_text = tokenizer.batch_decode(outputs[0], skip_special_tokens=True)     return (final_text) demo = gr.Interface(                                                          fn=gen_text,     ...