object has no attribute 'visible_device_list' - tensorflow

I'm trying to extract faces from pics but in some where I hit this error:
my code:
config = tf.compat.v1.ConfigProto #tf.ConfigProto()
config.gpu_options.visible_device_list ='0'
and the error I get:
AttributeError: 'google.protobuf.pyext._message.FieldProperty' object has no attribute 'visible_device_list'
If there is help, I will be thankful.

just need to add two parentheses!
config = tf.compat.v1.ConfigProto()

Related

AttributeError: 'coroutine' object has no attribute 'chats'

Stopped working on telethon v2 how can I fix this?
chat_list = self.client(_tl.fn.contacts.Search(q=key, limit=100)).chats
try;
_chat_list = await self.client(_tl.fn.contacts.Search(q=key, limit=100))
chat_list = _chat_list.chats

Make Pydantic chuck error for wrong argument names

Suppose I have the following class:
class ModelConfig(pydantic.BaseModel):
name: str = "bert"
If I were to instantiate it with model_config = ModelConfig(name2="hello"), this simply ignores that there is no name2 and just keeps name="bert". Is there a way to raise an error saying unknown argument in pydantic?
You can do this using the forbid Model Config
For example:
class ModelConfig(pydantic.BaseModel, extra=pydantic.Extra.forbid):
name: str = "bert"
Passing model_config = ModelConfig(name2="hello") will throw an error

Cannot pass parameters into a .rdlc file

I receive an error when running the following code. It throws an error when i try to set the parameters on the report. I looked everywhere but cannot seem to find an answer what I am doing wrong here. Every example has this method to pass parameters. Any insight would be greatly appreciated.
Me.ReportViewer1.Clear()
Me.ReportViewer1.LocalReport.ReportEmbeddedResource = "Stock_Centric.OrderPrint.rdlc"
Me.ReportViewer1.LocalReport.DataSources.Clear()
Me.ReportViewer1.LocalReport.DataSources.Add(NewMicrosoft.Reporting.WinForms.ReportDataSource("dsOrderItems", dtItems.DefaultView))
Me.ReportViewer1.SetDisplayMode(Microsoft.Reporting.WinForms.DisplayMode.PrintLayout)
Dim paramtr(4) As ReportParameter
paramtr(0) = New ReportParameter("Type", "Sale")
paramtr(1) = New ReportParameter("Company", "Jabu")
paramtr(2) = New ReportParameter("Direction", "Out")
paramtr(3) = New ReportParameter("OrderNum", "53")
paramtr(4) = New ReportParameter("Reference", "Kukashop 123")
ReportViewer1.LocalReport.SetParameters(paramtr)
Me.ReportViewer1.RefreshReport()
Error: System.InvalidCastException: 'Unable to cast object of type 'Microsoft.Reporting.WebForms.ReportParameter[]' to type 'System.Collections.Generic.IEnumerable`1[Microsoft.Reporting.WinForms.ReportParameter]'.'
All your parameters are in a form of strings?

Adding a Retokenize pipe while training NER model

I am currenly attempting to train a NER model centered around Property Descriptions. I could get a fully trained model to function to my liking however, I now want to add a retokenize pipe to the model so that I can set up the model to train other things.
From here, I am having issues getting the retokenize pipe to actually work. Here is the definition:
def retok(doc):
ents = [(ent.start, ent.end, ent.label) for ent in doc.ents]
with doc.retokenize() as retok:
string_store = doc.vocab.strings
for start, end, label in ents:
retok.merge(
doc[start: end],
attrs=intify_attrs({'ent_type':label},string_store))
return doc
i am adding it into my training like this:
nlp.add_pipe(retok, after="ner")
and I am adding it into the Language Factories like this:
Language.factories['retok'] = lambda nlp, **cfg: retok(nlp)
The issue I keep getting is "AttributeError: 'English' object has no attribute 'ents'". Now I am assuming I am getting this error because the parameter that is being passed through this function is not a doc but actually the NLP model itself. I am not really sure to get a doc to flow into this pipe during training. At this point I don't really know where to go from here to get the pipe to function the way I want.
Any help is appreciated, thanks.
You can potentially use the built-in merge_entities pipeline component: https://spacy.io/api/pipeline-functions#merge_entities
The example copied from the docs:
texts = [t.text for t in nlp("I like David Bowie")]
assert texts == ["I", "like", "David", "Bowie"]
merge_ents = nlp.create_pipe("merge_entities")
nlp.add_pipe(merge_ents)
texts = [t.text for t in nlp("I like David Bowie")]
assert texts == ["I", "like", "David Bowie"]
If you need to customize it further, the current implementation of merge_entities (v2.2) is a good starting point:
def merge_entities(doc):
"""Merge entities into a single token.
doc (Doc): The Doc object.
RETURNS (Doc): The Doc object with merged entities.
DOCS: https://spacy.io/api/pipeline-functions#merge_entities
"""
with doc.retokenize() as retokenizer:
for ent in doc.ents:
attrs = {"tag": ent.root.tag, "dep": ent.root.dep, "ent_type": ent.l
abel}
retokenizer.merge(ent, attrs=attrs)
return doc
P.S. You are passing nlp to retok() below, which is where the error is coming from:
Language.factories['retok'] = lambda nlp, **cfg: retok(nlp)
See a related question: Spacy - Save custom pipeline

Getting an invalid token on an interpolated string sent from python/jinga2 backend

I'm sending a variable called apiID from a tornado/jinja2 python file to my vuejs template like this:
class SmartAPIUIHandler(BaseHandler):
def get(self, yourApiID):
doc_file = "smartapi-ui.html"
dashboard_template = templateEnv.get_template(doc_file)
dashboard_output = dashboard_template.render(apiID = yourApiID )
self.write(dashboard_output)
then in vuejs I'm interpolating the variable with no problem except it gives me an error
it says: Uncaught SyntaxError: Invalid or unexpected token
I checked on the python handler file and apipID is a string, so I don't see the problem. I'm quite new to python so maybe the answer is more obvious to one of you. I appreciate the help!!
Because of dashboard_output = dashboard_template.render(apiID = yourApiID ), you must have, in your template, something around the code:
this.apiID = {{ apiID }};
Due to the value being not a number but a string, add the 's:
this.apiID = '{{ apiID }}';